czardas Posted July 21, 2012 Share Posted July 21, 2012 (edited) I seem to have run into this problem. Somehow it seems familiar to me, but I have no idea what is causing it. Run the GUI and navigate to the first menu item 'New'. As soon as you click the message box that appears, the GUI disappears behind the next active window. That's not what the code tells it to do. Has anyone any idea how to disable the GUI without this unwanted behaviour? expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <EditConstants.au3> _Main() Func _Main() Local $sWinTitle $sWinTitle = "Reproducer Window" Local $hGUI = GUICreate($sWinTitle, 600, 400, Default, Default, BitOR($WS_OVERLAPPEDWINDOW, $WS_EX_COMPOSITED)) $ahMenuItem = _CreateMenus() Local $hEdit1 _CreateEdit($hEdit1) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg Case $ahMenuItem[2], $GUI_EVENT_CLOSE ; Exit Exit Case $ahMenuItem[1] ; New GUISetState(@SW_DISABLE, $hGUI) MsgBox(0, "Message", "New") GUISetState(@SW_ENABLE, $hGUI) ; GUI disappears behind other windows. Why? EndSwitch WEnd EndFunc ;==>_Main Func _CreateEdit(ByRef $hEdit) Local $dStyle = BitOR($ES_WANTRETURN, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_NOHIDESEL) $hEdit = GUICtrlCreateEdit("", 0, 10, 600, 380, $dStyle, $WS_EX_LAYERED) GUICtrlSetResizing($hEdit, BitOR($GUI_DOCKLEFT, $GUI_DOCKTOP, $GUI_DOCKBOTTOM)) EndFunc ;==> _CreateEdit Func _CreateMenus() Local $ahMenu[2] = [1, "File"] Local $ahMenuItem[3] = [2, _ "New", _ "Exit"] Local $iItemCount = 1 ; FILE $ahMenu[1] = GUICtrlCreateMenu($ahMenu[1]) ; File For $i = $iItemCount To $iItemCount + 1 $ahMenuItem[$iItemCount] = GUICtrlCreateMenuItem($ahMenuItem[$iItemCount], $ahMenu[1]) $iItemCount += 1 Next Return $ahMenuItem EndFunc ;==>_CreateMenus Edited July 21, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
NicePerson Posted July 21, 2012 Share Posted July 21, 2012 Use GUISetState(@SW_RESTORE, $hGUI) after enabling the GUI that will solve the problem. Link to comment Share on other sites More sharing options...
czardas Posted July 21, 2012 Author Share Posted July 21, 2012 (edited) Use GUISetState(@SW_RESTORE, $hGUI) after enabling the GUI that will solve the problem.Thanks, but there are two problems with this suggestion: Firstly the window may be maximised, in which case the GUI will restore down. Secondly I need to disable the GUI in 40 or more different circumstances, so the number of additional lines of code may become excessive. I really want just one or two lines of code to fix it permanently if possible (or a better solution).BTW If you remove the message box from the script the window remains on top. Edited July 21, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 21, 2012 Moderators Share Posted July 21, 2012 czardas,When I run your script, the GUI remains on top but also remains inactive when the MsgBox is closed. Adding a WinActivate line solves that. I realise that you are probably not merely running a MsgBox when that menu item is actioned, but could I point out that if you were then you could avoid the problem by making the MsgBox modal - then your GUI is automatically disabled when the dialog is preset. The Modal MsgBox Styles tutorial in the Wiki explains the various modal states. 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...
czardas Posted July 21, 2012 Author Share Posted July 21, 2012 (edited) Thanks Melba, that's solved it. Less code needed than I had already. MsgBox(8243, "", "Do you want to save changes")I still wonder why the GUI diappears on my machine and not yours. Edited July 21, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
AZJIO Posted July 21, 2012 Share Posted July 21, 2012 Case $ahMenuItem[1] ; New ; GUISetState(@SW_DISABLE, $hGUI) MsgBox(0, "Message", "New", 0, $hGUI) ; GUISetState(@SW_ENABLE, $hGUI) ; GUI disappears behind other windows. Why? My other projects or all 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