TommyDDR Posted August 26, 2014 Share Posted August 26, 2014 (edited) Hello there,I am confronted with a problem of window creation, associated with events (or GUI_EVENT_XXX WM_XXX).Here's my problem:A fairly heavy window (> 4000 controls) is created during an event, time of creation is "too long" and if during that time I get another event, then the second window is created, then the program returns to the first to finish his work, but there window "active" (where controls are created) changed. The new controls are created on the second window.Is there a way to force the creation of a label, input, etc, specifying the window?Here's an example of my problem (run the program and click fast on close) We see that "Label gui : 0" is on $gui[1] #include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Opt("GuiOnEventMode", 1) Global $gui[2] Global $label[2] Global $taille[2] = [200, 100] CreateGui(0) While(True) Sleep(10) WEnd Func CreateGui($guiNumber) $gui[$guiNumber] = GUICreate("", $taille[0], $taille[1], 500+$taille[0]*$guiNumber, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $gui) GUICtrlCreateLabel("Label", 10, 20) GUISetState(@SW_SHOW, $gui) For $i = 1 To 4000 GUICtrlCreateLabel("simulation 4000 controls", $taille[0]+10, 0) Next GUICtrlCreateLabel("Label gui : " & $guiNumber, 10, 40+$guiNumber*20) EndFunc Func close() If(IsHWnd($gui[1])) Then Exit Else CreateGui(1) EndIf EndFunc Edited August 26, 2014 by TommyDDR _GUIRegisterMsg (Register more than 1 time the same Msg), _Resize_Window (GUICtrlSetResizing for children windows), _GUICtrlSetOnHover (Link a function when mouse go on, left, clic down, clic up, on a control), _InputHeure (Create an input for hour contain), _GUICtrlCalendar (Make a complete calendar), _GUICtrlCreateGraphic3D (Create a 3D graph), _ArrayEx.au3 (Array management), _GUIXViewEx.au3 (List/Tree View management). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 26, 2014 Moderators Share Posted August 26, 2014 TommyDDR,Setting GUISwitch to the first GUI should solve the problem: Func close() If (IsHWnd($gui[1])) Then Exit Else CreateGui(1) EndIf GUISwitch($gui[0]) EndFunc ;==>closeAlthough I would suggest that stopping OnEvent mode during the control creation cycle would probably be a better solution. 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...
TommyDDR Posted August 26, 2014 Author Share Posted August 26, 2014 (edited) Thank's for your answer. I actually created a window when the TCP event "NewClient" appears, therefore I do not choose when they connect and I can not stop listening and miss connections.GUISwitch works if you know the GUI to switch, but in my case I can't know it advance, Is there way to know the GUI that is being used to create the controls?Otherwise, I can create a table by storing the window being created and switch at the end of creation if another preceding it. Edited August 26, 2014 by TommyDDR _GUIRegisterMsg (Register more than 1 time the same Msg), _Resize_Window (GUICtrlSetResizing for children windows), _GUICtrlSetOnHover (Link a function when mouse go on, left, clic down, clic up, on a control), _InputHeure (Create an input for hour contain), _GUICtrlCalendar (Make a complete calendar), _GUICtrlCreateGraphic3D (Create a 3D graph), _ArrayEx.au3 (Array management), _GUIXViewEx.au3 (List/Tree View management). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 26, 2014 Moderators Share Posted August 26, 2014 TommyDDR,If you are going to create these (possibly infinite) recursive functions then you will have such problems. Can you not store the new connection and then process it once the control creation has ended? Otherwise I would suggest storing the current GUI handle and then switching back when the new GUI is complete - like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Opt("GuiOnEventMode", 1) Global $gui[2] Global $label[2] Global $taille[2] = [200, 200] Global $aActive[1] = [0] CreateGui(0) While (True) Sleep(10) WEnd Func CreateGui($guiNumber) $gui[$guiNumber] = GUICreate("", $taille[0], $taille[1], 500 + $taille[0] * $guiNumber, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $gui) GUICtrlCreateLabel("Label", 10, 10) GUISetState(@SW_SHOW, $gui) For $i = 1 To 50 GUICtrlCreateLabel($i, 20, $i + 20) Sleep(100) Next GUICtrlCreateLabel("Label gui : " & $guiNumber, 10, 40) ; Is there another GUI waiting to complete? If UBound($aActive) > 1 Then ; Switch to it GUISwitch($aActive[$aActive[0]]) ; And remove it from the array ReDim $aActive[$aActive[0]] $aActive[0] -= 1 EndIf EndFunc ;==>CreateGui Func close() If (IsHWnd($gui[1])) Then Exit Else ; Get the current creation GUI Local $hCurrent_GUI = GUISwitch(WinGetHandle(AutoItWinGetTitle())) ; And store it $aActive[0] += 1 ReDim $aActive[$aActive[0] + 1] $aActive[$aActive[0]] = $hCurrent_GUI ; Now create the new one CreateGui(1) EndIf GUISwitch($gui[0]) EndFunc ;==>closeThat seems to work - as long as you can accept the delay in completing the interrupted GUI. 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...
TommyDDR Posted August 26, 2014 Author Share Posted August 26, 2014 GUISwitch(WinGetHandle(AutoItWinGetTitle())) is exactly what i want, thank you Melba _GUIRegisterMsg (Register more than 1 time the same Msg), _Resize_Window (GUICtrlSetResizing for children windows), _GUICtrlSetOnHover (Link a function when mouse go on, left, clic down, clic up, on a control), _InputHeure (Create an input for hour contain), _GUICtrlCalendar (Make a complete calendar), _GUICtrlCreateGraphic3D (Create a 3D graph), _ArrayEx.au3 (Array management), _GUIXViewEx.au3 (List/Tree View management). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 26, 2014 Moderators Share Posted August 26, 2014 TommyDDR,My pleasure. 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...
TommyDDR Posted September 16, 2014 Author Share Posted September 16, 2014 (edited) After several tests, it seems that GUISwitch fail (and return 0x000000000) onWinGetHandle(AutoItWinGetTitle())We should not have the access for switching on it. Your script works thanks toGUISwitch($gui[0])of the close function .The solution (not clean) is to create a "ghost" GUI for switching on. If you have a better solution...expandcollapse popup#include <GUIConstantsEx.au3> #include <SendMessage.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Opt("GuiOnEventMode", 1) Global $gui[2] Global $label[2] Global $taille[2] = [200, 200] Global $aActive[1] = [0] Global $guiGhost = GUICreate("") CreateGui(0) While (True) Sleep(10) WEnd Func CreateGui($guiNumber) $gui[$guiNumber] = GUICreate("", $taille[0], $taille[1], 500 + $taille[0] * $guiNumber, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "close", $gui) GUICtrlCreateLabel("Label", 10, 10) GUISetState(@SW_SHOW, $gui) For $i = 1 To 20 GUICtrlCreateLabel($i, 20, $i + 20) Sleep(100) Next GUICtrlCreateLabel("Label gui : " & $guiNumber, 10, 40) ; Is there another GUI waiting to complete? If UBound($aActive) > 1 Then ; Switch to it GUISwitch($aActive[$aActive[0]]) ; And remove it from the array ReDim $aActive[$aActive[0]] $aActive[0] -= 1 EndIf EndFunc ;==>CreateGui Func close() If (IsHWnd($gui[1])) Then Exit Else ; Get the current creation GUI Local $hCurrent_GUI = GUISwitch($guiGhost) ; And store it $aActive[0] += 1 ReDim $aActive[$aActive[0] + 1] $aActive[$aActive[0]] = $hCurrent_GUI ; Now create the new one CreateGui(1) EndIf EndFunc ;==>close Edited September 16, 2014 by TommyDDR _GUIRegisterMsg (Register more than 1 time the same Msg), _Resize_Window (GUICtrlSetResizing for children windows), _GUICtrlSetOnHover (Link a function when mouse go on, left, clic down, clic up, on a control), _InputHeure (Create an input for hour contain), _GUICtrlCalendar (Make a complete calendar), _GUICtrlCreateGraphic3D (Create a 3D graph), _ArrayEx.au3 (Array management), _GUIXViewEx.au3 (List/Tree View management). 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