Sign in to follow this  
Followers 0
lookfar

GroupBox and child controls

4 posts in this topic

when inserting a radio button or checkbox inside a groupbox within a IDE like Delphi or VB or VC++, the component inherits the propertys of the parent so that one can move the groupbox and all the controls inside move with it, the controls are owned by the parent. The Top,Left,Width and Height are based off the Parent and not the form.

when I insert a radio button using :

$GroupBox1 = GuiCtrlCreateGroup("GroupBox1", 96, 48, 185, 105)

$RadioButton1 = GuiCtrlCreateRadio("RadioButton1", 16, 16, 113, 17)

The radio button should be inside the groupbox, but in fact the radio button ends up outside the groupbox because it is still owned by the main form and not the groupbox.

I cannot seem to find any reference to this in the help file..

Can I set "Parent" as a parameter of a control?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

perhaps using

$GroupBox1 = GuiCtrlCreateGroup("GroupBox1", 96, 48, 185, 105)
Opt("GUICoordMode", 0)      ;1=absolute, 0=relative, 2=cell
$RadioButton1 = GuiCtrlCreateRadio("RadioButton1", 16, 16, 113, 17)

if that doesn't work then you could add the group and radio's to a child window on the parent form

Edited by quaizywabbit

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites

perhaps using

$GroupBox1 = GuiCtrlCreateGroup("GroupBox1", 96, 48, 185, 105)
Opt("GUICoordMode", 0)     ;1=absolute, 0=relative, 2=cell
$RadioButton1 = GuiCtrlCreateRadio("RadioButton1", 16, 16, 113, 17)

if that doesn't work then you could add the group and radio's to a child window on the parent form

<{POST_SNAPBACK}>

Well that works if there is only one control in the groupbox but as soon as you put more than one they shuffle over to the right:

#include <GuiConstants.au3>
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
GuiCreate("Form1", 420, 331, 302,218 ,$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GroupBox1 = GuiCtrlCreateGroup("GroupBox1", 168, 32, 185, 105)
Opt("GUICoordMode", 0)
$CheckBox1 = GuiCtrlCreateCheckbox("CheckBox1", 24, 24, 97, 17 ); lines up ok
$CheckBox2 = GuiCtrlCreateCheckbox("CheckBox2", 24, 48, 97, 17 ); wrong alignment
Opt("GUICoordMode", 1)
$Button1 = GuiCtrlCreateButton("Button1", 8, 8, 75, 25); button is outside,good

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        
    EndSelect
WEnd
Exit

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Well that works if there is only one control in the groupbox but as soon as you put more than one they shuffle over to the right:

#include <GuiConstants.au3>
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
GuiCreate("Form1", 420, 331, 302,218 ,$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GroupBox1 = GuiCtrlCreateGroup("GroupBox1", 168, 32, 185, 105)
Opt("GUICoordMode", 0)
$CheckBox1 = GuiCtrlCreateCheckbox("CheckBox1", 24, 24, 97, 17 ); lines up ok
$CheckBox2 = GuiCtrlCreateCheckbox("CheckBox2", 24, 48, 97, 17 ); wrong alignment
Opt("GUICoordMode", 1)
$Button1 = GuiCtrlCreateButton("Button1", 8, 8, 75, 25); button is outside,good

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        
    EndSelect
WEnd
Exit

<{POST_SNAPBACK}>

try this instead:
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000
GuiCreate("Form1", 420, 331, 302,218 ,$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GroupBox1 = GuiCtrlCreateGroup("GroupBox1", 168, 32, 185, 105)
Opt("GUICoordMode", 0)
$CheckBox1 = GuiCtrlCreateCheckbox("CheckBox1", 24, 24, 97, 17 ); lines up ok
$CheckBox2 = GuiCtrlCreateCheckbox("CheckBox2", -1, 48, 97, 17 ); -1 lines up control from previous control during 'relative coord mode'
Opt("GUICoordMode", 1)
$Button1 = GuiCtrlCreateButton("Button1", 8, 8, 75, 25); button is outside,good

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        
    EndSelect
WEnd
Exit
Edited by quaizywabbit

[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
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
Sign in to follow this  
Followers 0