aa2zz6 Posted August 18, 2020 Share Posted August 18, 2020 Why is button $btnWorkforce keep pushing the child GUI away from the parent GUI? It has the exact same code as button $btnDashboard and that works perfectly. Is there an easier way to write this so multiple child gui's work the same? expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ColorConstants.au3> #include <ButtonConstants.au3> ; List App Varibles Local $hGUI_Child_Workforce Local $hGUI_Child_Dashboard $hGUI_Main = GUICreate("", 250, 300) ; Create Child GUI [1] _Create_Child_Workforce($hGUI_Main) GUIRegisterMsg($WM_MOVE, "_Position_Child_Workforce") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY_WORKFORCE") ; Create Child GUI [2] _Create_Child_Dashboard($hGUI_Main) GUIRegisterMsg($WM_MOVE, "_Position_Child_Dashboard") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY_DASHBOARD") GUISetState(@SW_SHOW, $hGUI_Main) ; Create app BTN [1] $btnWorkforce = IconButton("Workforce", 15, 25, 140, 40, 30, @ScriptDir & "\workforce.ico") ; Create app BTN [2] $btnDashboard = IconButton("Dashboard", 15, 80, 140, 40, 30, @ScriptDir & "\operations-dashboard.ico") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ; List [case $....] for button apps Case $btnWorkforce _All_Hide() GUISetState(@SW_SHOW, $hGUI_Child_Workforce) Case $btnDashboard _All_Hide() GUISetState(@SW_SHOW, $hGUI_Child_Dashboard) EndSwitch WEnd Func _All_Hide() GUISetState(@SW_HIDE, $hGUI_Child_Workforce) GUISetState(@SW_HIDE, $hGUI_Child_Dashboard) EndFunc ;==>_All_Hide ; Functions for ~ Workfoce [1] Func _Create_Child_Workforce($hGUI_Main) Local $lnCount = 600 $hGUI_Child_Workforce = GUICreate("Follower", 800, $lnCount, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) GUISetBkColor(0xCCFFCC) GUISetFont(11, 400, Default, "Arial") Global $text = GUICtrlCreateLabel("Workforce", 10, 10, 380, ($lnCount * 20) - 20) _Position_Child_Workforce($hGUI_Main, 0, 0, 0) GUISetState(@SW_HIDE, $hGUI_Child_Workforce) EndFunc ;==>_Create_Child Func _Position_Child_Workforce($hGUI_Main, $iMsg, $wParam, $lParam) Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) WinMove($hGUI_Child_Workforce, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1]) EndFunc ;==>_Position_Child Func _SH_Child_Workforce($hGUI_Main, $sText, $sLength) GUISetState(@SW_SHOW, $hGUI_Child_Workforce) GUICtrlSetData($text, $sText) WinActivate($hGUI_Main) Sleep($sLength) GUISetState(@SW_HIDE, $hGUI_Child_Workforce) GUICtrlSetData($text, "123") EndFunc ;==>_SH_Child Func _WM_NOTIFY_WORKFORCE($nWnd, $iMsg = "", $wParam = "", $lParam = "") Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) = $NM_CLICK Then ; Code $hCurrListView = DllStructGetData($tStruct, 1) ; ListView handle EndIf EndFunc ;==>_WM_NOTIFY ; Functions for ~ Dashboard [2] Func _Create_Child_Dashboard($hGUI_Main) Local $lnCount = 600 $hGUI_Child_Dashboard = GUICreate("Follower", 800, $lnCount, -1, -1, BitOR($WS_POPUP, $WS_BORDER), 0, $hGUI_Main) GUISetBkColor(0xCCFFCC) GUISetFont(11, 400, Default, "Arial") Global $text = GUICtrlCreateLabel("Dashboard", 10, 10, 380, ($lnCount * 20) - 20) _Position_Child_Dashboard($hGUI_Main, 0, 0, 0) GUISetState(@SW_HIDE, $hGUI_Child_Dashboard) EndFunc ;==>_Create_Child Func _Position_Child_Dashboard($hGUI_Main, $iMsg, $wParam, $lParam) Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) WinMove($hGUI_Child_Dashboard, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1]) EndFunc ;==>_Position_Child Func _SH_Child_Dashboard($hGUI_Main, $sText, $sLength) GUISetState(@SW_SHOW, $hGUI_Child_Dashboard) GUICtrlSetData($text, $sText) WinActivate($hGUI_Main) Sleep($sLength) GUISetState(@SW_HIDE, $hGUI_Child_Dashboard) GUICtrlSetData($text, "") EndFunc ;==>_SH_Child Func _WM_NOTIFY_DASHBOARD($nWnd, $iMsg = "", $wParam = "", $lParam = "") Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam) If BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) = $NM_CLICK Then ; Code $hCurrListView = DllStructGetData($tStruct, 1) ; ListView handle EndIf EndFunc ;==>_WM_NOTIFY Func IconButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconSize, $BIDLL, $BIconNum = -1) GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + (($BIheight - $BIconSize) / 2), $BIconSize, $BIconSize) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DISABLE) $XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS) Return $XS_btnx EndFunc ;==>IconButton Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 18, 2020 Moderators Share Posted August 18, 2020 aa2zz6, You cannot register 2 functions to the same message - you need to use just one function and then determine which of the child GUIs sent the message within the handler so as to run the correct code. 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...
pixelsearch Posted August 18, 2020 Share Posted August 18, 2020 (edited) @aa2zz6 : I tried a different approach for the position of child GUI's in this simplified script. Hope it helps expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; List App Variables Global $hGUI_Child_Workforce, $hGUI_Child_Dashboard, $hGUI_Main = GUICreate("", 250, 300) ; Create app BTN [1] $btnWorkforce = IconButton("Workforce", 15, 25, 140, 40, 30, @ScriptDir & "\workforce.ico") ; Create app BTN [2] $btnDashboard = IconButton("Dashboard", 15, 80, 140, 40, 30, @ScriptDir & "\operations-dashboard.ico") ; Create Child GUI [1] _Create_Child_Workforce($hGUI_Main) ; Create Child GUI [2] _Create_Child_Dashboard($hGUI_Main) GUIRegisterMsg($WM_MOVE, "_Position_Child") GUISetState(@SW_SHOW, $hGUI_Main) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $btnWorkforce GUISetState(@SW_HIDE, $hGUI_Child_Dashboard) GUISetState(@SW_SHOW, $hGUI_Child_Workforce) Case $btnDashboard GUISetState(@SW_HIDE, $hGUI_Child_Workforce) GUISetState(@SW_SHOW, $hGUI_Child_Dashboard) EndSwitch WEnd ;====================================== Func IconButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconSize, $BIDLL, $BIconNum = -1) GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + (($BIheight - $BIconSize) / 2), $BIconSize, $BIconSize) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DISABLE) $XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS) Return $XS_btnx EndFunc ;==>IconButton ;====================================== Func _Create_Child_Workforce($hGUI_Main) Local $lnCount = 600 Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) $hGUI_Child_Workforce = GUICreate("Follower 1", 800, $lnCount, $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1], _ BitOR($WS_POPUP, $WS_BORDER), -1, $hGUI_Main) GUISetBkColor(0xCCFFCC) GUISetFont(11, 400, Default, "Arial") Local $text = GUICtrlCreateLabel("Workforce", 10, 10, 380, ($lnCount * 20) - 20) EndFunc ;==>_Create_Child_Workforce ;====================================== Func _Create_Child_Dashboard($hGUI_Main) Local $lnCount = 600 Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) $hGUI_Child_Dashboard = GUICreate("Follower 2", 800, $lnCount, $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1], _ BitOR($WS_POPUP, $WS_BORDER), -1, $hGUI_Main) GUISetBkColor(0xCCFFCC) GUISetFont(11, 400, Default, "Arial") Local $text = GUICtrlCreateLabel("Dashboard", 10, 10, 380, ($lnCount * 20) - 20) EndFunc ;==>_Create_Child_Dashboard ;====================================== Func _Position_Child($hGUI_Main, $iMsg, $wParam, $lParam) Local $aGUI_Main_Pos = WinGetPos($hGUI_Main) WinMove($hGUI_Child_Workforce, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1]) WinMove($hGUI_Child_Dashboard, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1]) ; Return $GUI_RUNDEFMSG ; (?) EndFunc ;==>_Position_Child workforce.ico operations-dashboard.ico Edited August 18, 2020 by pixelsearch deleted a few more lines, still ok for child GUI's position aa2zz6 1 Link to comment Share on other sites More sharing options...
aa2zz6 Posted August 19, 2020 Author Share Posted August 19, 2020 @pixelsearch This is perfect!! Thank you! pixelsearch 1 Link to comment Share on other sites More sharing options...
pixelsearch Posted August 19, 2020 Share Posted August 19, 2020 aa2zz6 you're welcome, thanks for your "iconed buttons" in the script, very nice ! The following script gives the same result as the precedent one, though it doesn't register any message (because of the style you choosed for you child GUI's). It's a simpler approach which uses $WS_EX_MDICHILD as extended style for both child GUI's expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysInternals.au3> Global $hGUI_Child_Workforce, $hGUI_Child_Dashboard, $hGUI_Main = GUICreate("", 250, 300) $btnWorkforce = IconButton("Workforce", 15, 25, 140, 40, 30, @ScriptDir & "\workforce.ico") $btnDashboard = IconButton("Dashboard", 15, 80, 140, 40, 30, @ScriptDir & "\operations-dashboard.ico") _Create_Child($hGUI_Main) GUISetState(@SW_SHOW, $hGUI_Main) ;~ GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $btnWorkforce GUISetState(@SW_HIDE, $hGUI_Child_Dashboard) GUISetState(@SW_SHOW, $hGUI_Child_Workforce) Case $btnDashboard GUISetState(@SW_HIDE, $hGUI_Child_Workforce) GUISetState(@SW_SHOW, $hGUI_Child_Dashboard) EndSwitch WEnd ;====================================== Func IconButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $BIconSize, $BIDLL, $BIconNum = -1) GUICtrlCreateIcon($BIDLL, $BIconNum, $BIleft + 5, $BItop + (($BIheight - $BIconSize) / 2), $BIconSize, $BIconSize) GUICtrlSetResizing(-1, $GUI_DOCKALL) GUICtrlSetState(-1, $GUI_DISABLE) $XS_btnx = GUICtrlCreateButton($BItext, $BIleft, $BItop, $BIwidth, $BIheight, $WS_CLIPSIBLINGS) Return $XS_btnx EndFunc ;==>IconButton ;====================================== Func _Create_Child($hGUI_Main) Local $aGUI_Main_Pos = WinGetPos($hGUI_Main), $lnCount = 600 $hGUI_Child_Workforce = GUICreate("Follower 1", 800, $lnCount, -1, -1, _ BitOR($WS_POPUP, $WS_BORDER), $WS_EX_MDICHILD, $hGUI_Main) GUISetBkColor(0xCCFFCC) GUISetFont(11, 400, Default, "Arial") Local $text = GUICtrlCreateLabel("Workforce", 10, 10, 380, ($lnCount * 20) - 20) WinMove($hGUI_Child_Workforce, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1]) $hGUI_Child_Dashboard = GUICreate("Follower 2", 800, $lnCount, -1, -1, _ BitOR($WS_POPUP, $WS_BORDER), $WS_EX_MDICHILD, $hGUI_Main) GUISetBkColor(0xCCFFCC) GUISetFont(11, 400, Default, "Arial") Local $text = GUICtrlCreateLabel("Dashboard", 10, 10, 380, ($lnCount * 20) - 20) WinMove($hGUI_Child_Dashboard, "", $aGUI_Main_Pos[0] + $aGUI_Main_Pos[2], $aGUI_Main_Pos[1]) EndFunc ;==>_Create_Child ;====================================== ;~ Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) ;~ If $hWnd <> $hGUI_Main And BitAND($wParam,0xFFF0) = 0xF010 Then Return False ; $SC_MOVE = 0xF010 ;~ Return $GUI_RUNDEFMSG ;~ EndFunc Now here is an interesting test you could do : please notice the commented lines in the precedent script : ;~ GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") ;~ Func WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) ;~ If $hWnd <> $hGUI_Main And BitAND($wParam,0xFFF0) = 0xF010 Then Return False ; $SC_MOVE = 0xF010 ;~ Return $GUI_RUNDEFMSG ;~ EndFunc Actually you don't need them because your 2 child GUI's got this style : BitOR($WS_POPUP, $WS_BORDER) Which means you can't drag the child GUI's by themselves as they got no title bar... but what would happen if your child GUI's got a title bar ? Just test it, change the style of one of your child GUI from BitOR($WS_POPUP, $WS_BORDER) to -1 and see what happens now that a child GUI got a title bar : * If you keep the lines commented (WM_SYSCOMMAND) then you can drag the child GUI by its title bar, bad ! * If you uncomment the lines, (registering WM_SYSCOMMAND), then you can't drag the child GUI, great ! So in case you use this last script, it's not a bad idea to keep the commented lines within the script, maybe they will be useful one day ? Both icons required to run the script are downloadable at the end of the precedent message. Happy scripting aa2zz6 1 Link to comment Share on other sites More sharing options...
Skysnake Posted August 20, 2020 Share Posted August 20, 2020 @aa2zz6 have you looked at this? Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
aa2zz6 Posted August 27, 2020 Author Share Posted August 27, 2020 @pixelsearch You're amazing! Thanks again! 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