Jump to content

[Solved] Auto-resizing RichEdit control


zeffy
 Share

Recommended Posts

I know GUICtrlSetResizing() only works with the default autoit GUI controls, so I was wondering how I could use ControlMove() or something similar to accomplish the same thing?

Thanks :x

Edited by zeffy
Link to comment
Share on other sites

You have to handle the WM_SIZE message yourself unfortunately, and then use ControlMove (Or MoveWindow as I have). This means doing all the maths yourself as well, as you don't get the easy to use resizing flags.

This is a simple case with a 2px border on all sides, so the maths wasn't hard.

#include<GUIRichEdit.au3>
#include<WindowsConstants.au3>
#include<EditConstants.au3>
#include<WinAPI.au3>

Global $hGUI = GUICreate("Testing WM_SIZE", 350, 250, -1, -1, BitOR($WS_THICKFRAME, $WS_POPUP, $WS_CAPTION, $WS_SYSMENU))
Global $hRichEdit = _GUICtrlRichEdit_Create($hGUI, "This is a test.", 2, 2, 346, 246, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))

GUIRegisterMsg($WM_SIZE, "WM_SIZE")
GUISetState()

While True
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = -3
            _GUICtrlRichEdit_Destroy($hRichEdit)
            GUIDelete()
            Exit
    EndSelect
WEnd

Func WM_SIZE($hWnd, $iMsg, $wParam, $lParam)
    Local $iWidth = _WinAPI_LoWord($lParam)
    Local $iHeight = _WinAPI_HiWord($lParam)

    _WinAPI_MoveWindow($hRichEdit, 2, 2, $iWidth - 4, $iHeight - 4)

    Return 0
EndFunc   ;==>WM_SIZE
Link to comment
Share on other sites

You can dispense with the maths if you are as lazy as I am and easily deal with any resizing method that is available for standard controls. Draw a label and set the sizeand position to be the same as the richedit at design time, and set the resizing for that as you want. Then, when you handle the resizing for the richedit you only have to copy the label size and position (using ControlGetPos). Just set the label to not visible of course.

Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

  • 9 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...