Jump to content

Resize controls within a group automatically


Recommended Posts


Is it possible to dock all controls within a group control, to the borders of the group, in the same way as it is possible to dock controls to the borders of a GUI?

For example, in the following code, would it be possible to dock the edit control and OK and Cancel buttons to the surrounding group, so that when the Resize Group button is pressed, these controls within the group would resize automatically?

I know this can be done manually, but I was wondering if there is an easier way as this is just a simple example I have put together to illustrate the question. The real script I have in mind is much more complex, but the same principle applies.

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("AForm1", 307, 232, 296, 209)
GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close")
$Group1 = GUICtrlCreateGroup("", 10, 10, 287, 173)
$Edit1 = GUICtrlCreateEdit("", 20, 30, 273, 109, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
$cmdOK = GUICtrlCreateButton("OK", 18, 146, 77, 27, 0)
$cmdCancel = GUICtrlCreateButton("Cancel", 102, 146, 77, 27, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$cmdResize = GUICtrlCreateButton("Resize Group", 10, 192, 85, 29, 0)
GUICtrlSetOnEvent(-1, "cmdResizeClick")

While 1

Func AForm1Close()
Func cmdResizeClick()
    Local $group_pos = ControlGetPos($Form1, "", $Group1)
    ControlMove($Form1, "", $Group1, $group_pos[0], $group_pos[1], $group_pos[2], $group_pos[3] - 10)

Any suggestions would be much appreciated.



Link to comment
Share on other sites

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

  • Recently Browsing   0 members

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