sashaatx wrote: ↑19 Nov 2023, 05:50What's the best method for a parent GUI relationship.
Code: Select all
MainGui := Gui() MainGui.Show("w500 h500") childGUI := Gui("+Parent" MainGui.hwnd " -Caption") MainGui.Opt("+Resize +ToolWindow +MinSize250x150") MainGui.OnEvent("Size", GuiReSizer) childGUI.OnEvent("Size", GuiReSizer) ogcButtonOK := childGUI.Add("Button", "Default", "&OK") ogcButtonOK.WidthP := 0.48 ogcButtonOK.X := 10 childGUI.Show("x0 y0")
I couldnt figure out how to handle that relationship @FanaticGuru
The problem is that the Button size is tied to the size of the child Gui in which it resides. The child Gui size does not change size when the parent Gui changes size. This can be clearly seen if the -Caption flag is removed. Even if the Button size changed to match the parent Gui then it would not display in the still small child Gui.
Gui Controls are structured within the Gui in which they reside by Windows design.
GuiReSizer is not designed to tie Gui to other Gui or a Gui Control to a Gui other than the one in which it resides.
You can write a function to resize the child Gui whenever the parent Gui is resized, like this:
Code: Select all
MainGui := Gui()
MainGui.Show("w500 h500")
childGUI := Gui("+Parent" MainGui.hwnd " -Caption")
MainGui.Opt("+Resize +ToolWindow +MinSize250x150")
MainGui.OnEvent("Size", GuiReSizer)
childGUI.OnEvent("Size", GuiReSizer)
ogcButtonOK := childGUI.Add("Button", "Default", "&OK")
ogcButtonOK.WidthP := 0.48
ogcButtonOK.X := 10
childGUI.Show("x0 y0")
childGui.Maximize()
MainGui.Child := childGUI
MainGui.OnEvent("Size", childGUISize)
childGUISize(GuiObj, WindowMinMax, GuiW, GuiH)
{
GuiObj.Child.Move(, , GuiW, GuiH)
}
Having GuiReSizer being able to tie controls to other Gui in which they do not reside seems pretty problematic. I could see a use for tying a Gui to another Gui. That could probably be added to GuiReSizer. I am not sure if the utility is worth the complexity. I will probably play around with it.
FG