MartinGr Posted January 30, 2011 Share Posted January 30, 2011 (edited) Hi, I'm writing an application with a lot of controls, which for some reason shall be created on several child forms, and not on the main one. My problem: how to place a borderless child form as a part a big main window/form? This works and is placed in the top left corner of the main window: $ChildForm1 = GUICreate("", 1027, 83, 0,0, BitOR($WS_CHILD,$WS_TABSTOP,$WS_GROUP),0,$parent) But when I create a second child form, it is always layered over the first one - although its coordinates are of course not set to 0,0. How to place it below $ChildForm1? Regards, Martin Edited January 30, 2011 by MartinGr Link to comment Share on other sites More sharing options...
GEOSoft Posted January 30, 2011 Share Posted January 30, 2011 #Include<WindowsConstants.au3> $bShow = False $Frm_Main = GUICreate("Test Form", 300, 500, -1, -1) GUISetBkColor(0x00FF00) GUISetState() $Frm_Child_1 = GUICreate("First Child", 300, 200, 0, 0, $WS_CHILD, -1, $Frm_Main) $Btn_Disp = GUICtrlCreateButton("Toggle", 120, 90, 60, 30) GUISetBkColor(0xFF0000) GUISetState() $Frm_Child_2 = GUICreate("Second Child", 300, 250, 0, 220, $WS_CHILD, -1, $Frm_Main) GUISetBkColor(0x0000FF) While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 Exit Case $Btn_Disp If $bShow Then GUISetState(@SW_HIDE, $Frm_Child_2) Else GUISetState(@SW_SHOW, $Frm_Child_2) EndIf $bShow = NOT $bShow EndSwitch WEnd George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
MartinGr Posted February 1, 2011 Author Share Posted February 1, 2011 Thank you so much - that was convincing!! So I looked further into my code and found that I had a problem with the scope of my handle variable. So sorry for the question... Before I open another silly thread: My next problem is, that the tab key doesn't work in my child window. When the same form has the status $WS_POPUP instead of $WS_CHILD, I can browse though its controls - but when it's embedded in the main window, I lose this ability. Any idea for that? Thanks a lot, Martin Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 1, 2011 Moderators Share Posted February 1, 2011 MartinGr,Search the forum for $WS_EX_CONTROLPARENT. This style allows you to tab through the controls on child windows, but if I remember correctly has some side-effects on their "draggability". M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GEOSoft Posted February 1, 2011 Share Posted February 1, 2011 You will find that using different background colors to check Windows and control positioning is a good method for finding if there is an issue in that regard or not. Call it an oldtimers trick although it will make everything look ugly until you go back and remove the background colors. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 1, 2011 Moderators Share Posted February 1, 2011 George,an oldtimers trickAs I use that trick too, it must be for "oldtimers"! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GEOSoft Posted February 1, 2011 Share Posted February 1, 2011 You are the one to whom I was refering my good man.Besides I seem to recall giving you that same tip at one time. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
rover Posted February 2, 2011 Share Posted February 2, 2011 Re: WS_EX_CONTROLPARENT Greetings GEOSoft and Melba23 @MartinGr you can prevent a child dialog with WS_EX_CONTROLPARENT style from being dragged with a WM_NCHITTEST message handler. some background reference to the issue with the WS_EX_CONTROLPARENT style for anyone else reading this post. without that style, the child dialog is tabbed as one control. see Trac ticket #1115 for the reason this style has the side effect of making an AutoIt class child gui draggable. Ticket #1115 (closed Bug: No Bug) documentation for GuiCreate error http://www.autoitscript.com/trac/autoit/ticket/1115 a modification of GEOSoft's example above showing tabbing between controls on all three forms. expandcollapse popup;#include <WinAPI.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $Frm_Child_1, $Frm_Child_2 _Main() Func _Main() Local $bShow = False, $Msg Local $Frm_Main = GUICreate("Test Form", 300, 500, -1, -1) GUISetBkColor(0x00FF00) GUICtrlCreateButton("Main", 120, 470, 60, 30) $Frm_Child_1 = GUICreate("First Child", 300, 200, 0, 0, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $Frm_Main) Local $Btn_Disp = GUICtrlCreateButton("Toggle", 120, 90, 60, 30) GUISetBkColor(0xFF0000) GUISetState(@SW_SHOW, $Frm_Child_1) $Frm_Child_2 = GUICreate("Second Child", 300, 250, 0, 220, BitOR($WS_CHILD, $WS_TABSTOP), $WS_EX_CONTROLPARENT, $Frm_Main) GUISetBkColor(0x0000FF) GUICtrlCreateButton("Button1", 10, 20, 60, 30) GUICtrlCreateButton("Button2", 80, 20, 60, 30) GUICtrlCreateButton("Button3", 160, 20, 60, 30) GUICtrlCreateButton("Button4", 230, 20, 60, 30) GUIRegisterMsg($WM_NCHITTEST, "_WM_NCHITTEST") ;comment this line, and child forms with WS_EX_CONTROLPARENT style are draggable GUISetState(@SW_SHOW, $Frm_Main) While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 Exit Case $Btn_Disp If $bShow Then GUISetState(@SW_HIDE, $Frm_Child_2) Else GUISetState(@SW_SHOW, $Frm_Child_2) EndIf $bShow = NOT $bShow EndSwitch WEnd EndFunc Func _WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam) #forceref $iMsg, $iwParam, $ilParam Switch Number($hWnd) Case Number($Frm_Child_1), Number($Frm_Child_2) ;Local $iCode = _WinAPI_DefWindowProc($hWnd, $iMsg, $iwParam, $ilParam) ;If $iCode = 2 Then Return 1 ;Return $iCode Return 1 EndSwitch Return $GUI_RUNDEFMSG EndFunc robertocm 1 I see fascists... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 2, 2011 Moderators Share Posted February 2, 2011 rover, As usual you manage to cast light on some of the murkier areas of AutoIt coding. Thanks very much for that explanation. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now