Fraser Posted August 11, 2012 Posted August 11, 2012 Hello, I will start by saying, I'm sorry if this question has been asked before! Anyway as the title suggests I'm trying to attach a toolwindow GUI to the bottom of another GUI, so that when the main GUI is moved the attached goes with it. So far I’ve had no joy getting it to work and I can’t find anything to suggest how to go about doing it or if it is even possible. Any help and guidance will be greatly appreciated #region #AutoIt3Wrapper_Run_Tidy=y #AutoIt3Wrapper_Tidy_Stop_OnError=n #endregion #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $User_Naming_Program, $Form1 main() Func Main() $User_Naming_Program = GUICreate("User Naming Program", 402, 230) $Form1 = GUICreate("Form1", 219, 123, -1, -1, $WS_CHILD, $WS_EX_TOOLWINDOW, $User_Naming_Program) $Label1 = GUICtrlCreateLabel("Label1", 8, 8, 36, 17) $Group1 = GUICtrlCreateGroup("Group1", 8, 32, 201, 81) $next = GUICtrlCreateButton("NEXT", 10, 200, 180) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $next ;~ Child() EndSwitch WEnd EndFunc ;==>Main Thanks in advance Fraser
Moderators Melba23 Posted August 12, 2012 Moderators Posted August 12, 2012 Fraser, It certainly is possible - as you can see here: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI_Main = GUICreate("Main", 300, 300, 200, 200) GUISetBkColor(0xFFCCCC) $cButton = GUICtrlCreateButton("Show Child", 10, 10, 80, 30) GUISetState() $hGUI_Child = GUICreate("Follower", 304, 150, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) GUISetBkColor(0xCCFFCC) _Position_Child($hGUI_Main, 0, 0, 0) GUISetState(@SW_HIDE, $hGUI_Child) GUIRegisterMsg($WM_MOVE, "_Position_Child") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton Switch GUICtrlRead($cButton) Case "Show Child" GUISetState(@SW_SHOW, $hGUI_Child) GUICtrlSetData($cButton, "Hide Child") WinActivate($hGUI_Main) Case Else GUISetState(@SW_HIDE, $hGUI_Child) GUICtrlSetData($cButton, "Show Child") EndSwitch EndSwitch WEnd Func _Position_Child($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam If $hWnd <> $hGUI_Main Then Return Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) WinMove($hGUI_Child, "", $aGUI_Main_Pos[0], $aGUI_Main_Pos[1] + $aGUI_Main_Pos[3]) EndFunc ;==>_Position_Child Please ask if you have any questions. 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
Fraser Posted August 12, 2012 Author Posted August 12, 2012 Melba23, Thank you for your speedy response! This is brill, I’ve implemented it in to my code and it works flawlessly. Thank you Fraser
Moderators Melba23 Posted August 12, 2012 Moderators Posted August 12, 2012 Fraser, Glad I could help. 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
Fraser Posted August 12, 2012 Author Posted August 12, 2012 Melba23, I've thought of one question for you! I've played around with you script (out of curiosity) to see if I can get the child window to attach to the side of the main window, however it doesn’t seem to want to, is this also possible and if so am I doing it incorrectly? I tried tweaking the GUICreate Position variables to the following: $hGUI_Child = GUICreate("Follower", 304, 100, 100, 20, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) Thank you for your help Fraser
Moderators Melba23 Posted August 12, 2012 Moderators Posted August 12, 2012 Fraser, This is how you do it - look for the <<<<<<< lines: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI_Main = GUICreate("Main", 300, 300, 200, 200) GUISetBkColor(0xFFCCCC) $cButton = GUICtrlCreateButton("Show Child", 10, 10, 80, 30) GUISetState() $hGUI_Child = GUICreate("Follower", 150, 324, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) ; <<<<<<<<<<<<<< GUISetBkColor(0xCCFFCC) _Position_Child($hGUI_Main, 0, 0, 0) GUISetState(@SW_HIDE, $hGUI_Child) GUIRegisterMsg($WM_MOVE, "_Position_Child") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton Switch GUICtrlRead($cButton) Case "Show Child" GUISetState(@SW_SHOW, $hGUI_Child) GUICtrlSetData($cButton, "Hide Child") WinActivate($hGUI_Main) Case Else GUISetState(@SW_HIDE, $hGUI_Child) GUICtrlSetData($cButton, "Show Child") EndSwitch EndSwitch WEnd Func _Position_Child($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam If $hWnd <> $hGUI_Main Then Return Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) WinMove($hGUI_Child, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1]) ; <<<<<<<<<<<<<<<< EndFunc ;==>_Position_Child Please ask if you do not understand the changes I have made. 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
Fraser Posted August 12, 2012 Author Posted August 12, 2012 Melba23, Thank you for clarifying that, i understand how it works now Thank you very much for all your guidance Fraser
Moderators Melba23 Posted August 12, 2012 Moderators Posted August 12, 2012 Fraser,i understand how it works nowGood. Glad I could help. 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
armoros Posted August 17, 2012 Posted August 17, 2012 Yes very nice Melba23 But here i am trying to open multiple child guis to the bottom of the parent one but works only the first time. Any ideas. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI_Main = GUICreate("Main", 600, 400, 200, 200) GUISetBkColor(0xFFCCCC) $cButton = GUICtrlCreateButton("Show Child", 10, 10, 80, 30) $cButton1 = GUICtrlCreateButton("Show Child2", 50, 50, 80, 30) GUISetState() $hGUI_Child = GUICreate("Follower", 304, 150, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) GUISetBkColor(0xCCFFCC) _Position_Child($hGUI_Main, 0, 0, 0) GUISetState(@SW_HIDE, $hGUI_Child) $hGUI_Child2 = GUICreate("Follower", 304, 150, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) GUISetBkColor(0xCCFFCC) _Position_Child2($hGUI_Main, 0, 0, 0) GUISetState(@SW_HIDE, $hGUI_Child2) GUIRegisterMsg($WM_MOVE, "_Position_Child") GUIRegisterMsg($WM_MOVE, "_Position_Child2") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton Switch GUICtrlRead($cButton) Case "Show Child" GUISetState(@SW_SHOW, $hGUI_Child) GUICtrlSetData($cButton, "Hide Child") WinActivate($hGUI_Main) Case Else GUISetState(@SW_HIDE, $hGUI_Child) GUICtrlSetData($cButton, "Show Child") EndSwitch Case $cButton1 Switch GUICtrlRead($cButton1) Case "Show Child2" GUISetState(@SW_SHOW, $hGUI_Child2) GUICtrlSetData($cButton1, "Hide Child") WinActivate($hGUI_Main) Case Else GUISetState(@SW_HIDE, $hGUI_Child2) GUICtrlSetData($cButton1, "Show Child") EndSwitch EndSwitch WEnd Func _Position_Child($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam If $hWnd <> $hGUI_Main Then Return Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) WinMove($hGUI_Child, "", $aGUI_Main_Pos[0], $aGUI_Main_Pos[1] + $aGUI_Main_Pos[3]) EndFunc ;==>_Position_Child Func _Position_Child2($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam If $hWnd <> $hGUI_Main Then Return Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) WinMove($hGUI_Child2, "", $aGUI_Main_Pos[0], $aGUI_Main_Pos[1] + $aGUI_Main_Pos[3]) EndFunc ;==>_Position_Child2 [font="verdana, geneva, sans-serif"] [/font]
Moderators Melba23 Posted August 17, 2012 Moderators Posted August 17, 2012 armoros,The obvious problem is the 2 GUIRegisterMsg($WM_MOVE, ...) lines - only the second one will be honoured. You need to determine which GUI to track within a single handler. So, do you want only 1 GUI to be visible at a time or do you want the option of both? The answer will determine how we structure the handler. 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
armoros Posted August 17, 2012 Posted August 17, 2012 Thanks Melba23 Yes only 1 gui at a time,i open the one close the other etc. [font="verdana, geneva, sans-serif"] [/font]
Moderators Melba23 Posted August 17, 2012 Moderators Posted August 17, 2012 armoros, That makes it very easy: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Track which GUI is visible Global $iVisible = 0 $hGUI_Main = GUICreate("Main", 600, 400, 200, 200) GUISetBkColor(0xFFCCCC) $cButton_1 = GUICtrlCreateButton("Show Child 1", 10, 10, 80, 30) $cButton_2 = GUICtrlCreateButton("Show Child 2", 10, 50, 80, 30) GUISetState() $hGUI_Child_1 = GUICreate("Follower", 304, 150, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) GUISetBkColor(0xCCFFCC) GUISetState(@SW_HIDE, $hGUI_Child_1) $hGUI_Child_2 = GUICreate("Follower", 304, 150, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) GUISetBkColor(0xCCCCFF) GUISetState(@SW_HIDE, $hGUI_Child_2) GUIRegisterMsg($WM_MOVE, "_Position_Child") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_1 Switch GUICtrlRead($cButton_1) Case "Show Child 1" $iVisible = 1 ; Set the flag _Position_Child($hGUI_Main, 0, 0, 0) GUISetState(@SW_SHOW, $hGUI_Child_1) GUICtrlSetData($cButton_1, "Hide Child 1") GUICtrlSetState($cButton_2, $GUI_DISABLE) WinActivate($hGUI_Main) Case Else GUISetState(@SW_HIDE, $hGUI_Child_1) GUICtrlSetData($cButton_1, "Show Child 1") GUICtrlSetState($cButton_2, $GUI_ENABLE) $iVisible = 0 ; Clear the flag EndSwitch Case $cButton_2 Switch GUICtrlRead($cButton_2) Case "Show Child 2" $iVisible = 2 ; Set the flag _Position_Child($hGUI_Main, 0, 0, 0) GUISetState(@SW_SHOW, $hGUI_Child_2) GUICtrlSetData($cButton_2, "Hide Child 2") GUICtrlSetState($cButton_1, $GUI_DISABLE) WinActivate($hGUI_Main) Case Else GUISetState(@SW_HIDE, $hGUI_Child_2) GUICtrlSetData($cButton_2, "Show Child 2") GUICtrlSetState($cButton_1, $GUI_ENABLE) $iVisible = 0 ; Clear the flag EndSwitch EndSwitch WEnd Func _Position_Child($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam If $hWnd <> $hGUI_Main Then Return Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) ; Check the flag Switch $iVisible Case 0 Return Case 1 WinMove($hGUI_Child_1, "", $aGUI_Main_Pos[0], $aGUI_Main_Pos[1] + $aGUI_Main_Pos[3]) Case 2 WinMove($hGUI_Child_2, "", $aGUI_Main_Pos[0], $aGUI_Main_Pos[1] + $aGUI_Main_Pos[3]) EndSwitch EndFunc ;==>_Position_Child All clear? 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
armoros Posted August 17, 2012 Posted August 17, 2012 No words Melba23 You make our life easy,thank you. thats it. [font="verdana, geneva, sans-serif"] [/font]
Fraser Posted August 20, 2012 Author Posted August 20, 2012 (edited) Hi Melba23, Can i be cheeky and ask how you would go about making it so that both child windows can be open at the same time please? Thanks Fraser Edited August 20, 2012 by Fraser
Moderators Melba23 Posted August 20, 2012 Moderators Posted August 20, 2012 Fraser,Can i be cheeky and ask how you would go about making it so that both child windows can be open at the same time please?Of course: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Track which GUI is visible Global $iVisible = 0 $hGUI_Main = GUICreate("Main", 600, 400, 200, 200) GUISetBkColor(0xFFCCCC) $cButton_1 = GUICtrlCreateButton("Show Child 1", 10, 10, 80, 30) $cButton_2 = GUICtrlCreateButton("Show Child 2", 10, 50, 80, 30) GUISetState() $hGUI_Child_1 = GUICreate("Follower", 302, 150, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) GUISetBkColor(0xCCFFCC) GUISetState(@SW_HIDE, $hGUI_Child_1) $hGUI_Child_2 = GUICreate("Follower", 302, 150, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) GUISetBkColor(0xCCCCFF) GUISetState(@SW_HIDE, $hGUI_Child_2) GUIRegisterMsg($WM_MOVE, "_Position_Child") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton_1 Switch GUICtrlRead($cButton_1) Case "Show Child 1" $iVisible += 1 ; Set the flag for 1 visible _Position_Child($hGUI_Main, 0, 0, 0) GUISetState(@SW_SHOW, $hGUI_Child_1) GUICtrlSetData($cButton_1, "Hide Child 1") WinActivate($hGUI_Main) Case Else GUISetState(@SW_HIDE, $hGUI_Child_1) GUICtrlSetData($cButton_1, "Show Child 1") $iVisible -= 1 ; Clear the flag for 1 visible EndSwitch Case $cButton_2 Switch GUICtrlRead($cButton_2) Case "Show Child 2" $iVisible += 2 ; Set the flag for 2 visible _Position_Child($hGUI_Main, 0, 0, 0) GUISetState(@SW_SHOW, $hGUI_Child_2) GUICtrlSetData($cButton_2, "Hide Child 2") WinActivate($hGUI_Main) Case Else GUISetState(@SW_HIDE, $hGUI_Child_2) GUICtrlSetData($cButton_2, "Show Child 2") $iVisible -= 2 ; Clear the flag for 2 visible EndSwitch EndSwitch WEnd Func _Position_Child($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam, $lParam If $hWnd <> $hGUI_Main Then Return Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) ; Check the flag If $iVisible = 0 Then Return EndIf If BitAND($iVisible, 1) = 1 Then WinMove($hGUI_Child_1, "", $aGUI_Main_Pos[0], $aGUI_Main_Pos[1] + $aGUI_Main_Pos[3]) EndIf If BitAND($iVisible, 2) = 2 Then WinMove($hGUI_Child_2, "", $aGUI_Main_Pos[0] + 302, $aGUI_Main_Pos[1] + $aGUI_Main_Pos[3]) EndIf EndFunc ;==>_Position_ChildNote the manner in which the flag is set and checked - quite a useful trick which enables you to use a single parameter to indicate several independent choices. Please ask if you have any questions. 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
Fraser Posted August 20, 2012 Author Posted August 20, 2012 Melba23, Thank you for clarifying, much appreciated! Fraser
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