supersonic Posted February 22, 2013 Share Posted February 22, 2013 (edited) Hello, I notice a strange behavior in my script if I try to min./max./restore a window by (window title) button. It is possible to min. the window ONCE - any further try will result in lost window focus. To reproduce the behavior I stripped the script down: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $___WINDOW_HEIGHT = @DesktopHeight / 2 If $___WINDOW_HEIGHT < 400 Then $___WINDOW_HEIGHT = 400 EndIf Global $___WINDOW_HEIGHT_MIN = $___WINDOW_HEIGHT Global $___WINDOW_WIDTH = @DesktopWidth / 2 If $___WINDOW_WIDTH < 666 Then $___WINDOW_WIDTH = 666 EndIf Global $___WINDOW_WIDTH_MIN = $___WINDOW_WIDTH Global $hGUI1 = GUICreate("TEST1", $___WINDOW_WIDTH, $___WINDOW_HEIGHT, -1, -1, BitOR($WS_CAPTION, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_POPUP, $WS_SIZEBOX, $WS_SYSMENU), $WS_EX_TOPMOST, 0) Global $hGUI1_B4 = GUICtrlCreateButton("MIN", 1, 1, 100, 36) Global $hGUI1_B5 = GUICtrlCreateButton("MAX. / RESTORE", 102, 1, 100, 36) Global $hGUI1_B7 = GUICtrlCreateButton("EXIT", 202, 1, 100, 36) GUICtrlSetTip($hGUI1_B5, "Maximize main window to full screen.", "MAXIMIZE window.", 0, 0) GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") GUISetState(@SW_SHOW, $hGUI1) Local $aTmp1[1] = [0] Local $hMsg = 0 ; ---------------------------------------------------------------------------------------------------- $aTmp1 = WinGetPos($hGUI1, "") If Not @error Then $___WINDOW_HEIGHT_MIN = $aTmp1[3] $___WINDOW_WIDTH_MIN = $aTmp1[2] EndIf ; ---------------------------------------------------------------------------------------------------- While 1 $hMsg = GUIGetMsg(1) Switch $hMsg[1] Case $hGUI1 Switch $hMsg[0] Case $GUI_EVENT_CLOSE, $hGUI1_B7 ExitLoop Case $hGUI1_B4 GUISetState(@SW_MINIMIZE, $hMsg[1]) ;~ _SendMessage($hMsg[1], 0x0112, 0xF020, 0) ; $WM_SYSCOMMAND, $SC_MINIMIZE. ; [http://msdn.microsoft.com/en-us/library/ms646360.aspx]. Case $hGUI1_B5 If BitAND(WinGetState($hMsg[1], ""), 32) = 32 Then GUISetState(@SW_RESTORE, $hMsg[1]) Else ; Non-error. GUISetState(@SW_MAXIMIZE, $hMsg[1]) EndIf EndSwitch EndSwitch WEnd GUIDelete($hGUI1) Func _WM_GETMINMAXINFO($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam Switch $hWnd Case $hGUI1 Local $tagMINMAXINFO = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $ilParam) DllStructSetData($tagMINMAXINFO, 7, $___WINDOW_WIDTH_MIN) ; Min. X. DllStructSetData($tagMINMAXINFO, 8, $___WINDOW_HEIGHT_MIN) ; Min. Y. DllStructSetData($tagMINMAXINFO, 9, @DesktopWidth) ; Max. X. DllStructSetData($tagMINMAXINFO, 10, @DesktopHeight) ; Max. Y. ; ---------------------------------------------------------------------------------------------------- If BitAND(WinGetState($hWnd, ""), 32) = 32 Then GUICtrlSetTip($hGUI1_B5, "Restore main window to original position / size.", "RESTORE DOWN.") Else ; Non-error. GUICtrlSetTip($hGUI1_B5, "Maximize main window to full screen.", "MAXIMIZE window.") EndIf EndSwitch Return 0 EndFunc ;==>_WM_GETMINMAXINFO Somebody any idea? Greets, -supersonic. Edited February 22, 2013 by supersonic Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 22, 2013 Moderators Share Posted February 22, 2013 supersonic,It seems to be a problem with the WM_GETMINMAXINFO message handler interfering with the MINIMIZE command - if you disable the message handler before you minimize and re-enable it when you restore, everything seems to work (well it does for me): expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $___WINDOW_HEIGHT = @DesktopHeight / 2 If $___WINDOW_HEIGHT < 400 Then $___WINDOW_HEIGHT = 400 EndIf Global $___WINDOW_HEIGHT_MIN = $___WINDOW_HEIGHT Global $___WINDOW_WIDTH = @DesktopWidth / 2 If $___WINDOW_WIDTH < 666 Then $___WINDOW_WIDTH = 666 EndIf Global $___WINDOW_WIDTH_MIN = $___WINDOW_WIDTH Global $hGUI1 = GUICreate("TEST1", $___WINDOW_WIDTH, $___WINDOW_HEIGHT, -1, -1, BitOR($WS_CAPTION, $WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_POPUP, $WS_SIZEBOX, $WS_SYSMENU), $WS_EX_TOPMOST, 0) Global $hGUI1_B4 = GUICtrlCreateButton("MIN", 1, 1, 100, 36) Global $hGUI1_B5 = GUICtrlCreateButton("MAX. / RESTORE", 102, 1, 100, 36) Global $hGUI1_B7 = GUICtrlCreateButton("EXIT", 202, 1, 100, 36) GUICtrlSetTip($hGUI1_B5, "Maximize main window to full screen.", "MAXIMIZE window.", 0, 0) GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") GUISetState(@SW_SHOW, $hGUI1) Local $aTmp1[1] = [0] Local $hMsg = 0 ; ---------------------------------------------------------------------------------------------------- $aTmp1 = WinGetPos($hGUI1, "") If Not @error Then $___WINDOW_HEIGHT_MIN = $aTmp1[3] $___WINDOW_WIDTH_MIN = $aTmp1[2] EndIf ; ---------------------------------------------------------------------------------------------------- While 1 $hMsg = GUIGetMsg(1) Switch $hMsg[1] Case $hGUI1 Switch $hMsg[0] Case $GUI_EVENT_CLOSE, $hGUI1_B7 ExitLoop Case $GUI_EVENT_Restore GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Case $hGUI1_B4 GUIRegisterMsg($WM_GETMINMAXINFO, "") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState(@SW_MINIMIZE, $hMsg[1]) ;~ _SendMessage($hMsg[1], 0x0112, 0xF020, 0) ; $WM_SYSCOMMAND, $SC_MINIMIZE. ; [http://msdn.microsoft.com/en-us/library/ms646360.aspx]. Case $hGUI1_B5 If BitAND(WinGetState($hMsg[1], ""), 32) = 32 Then GUISetState(@SW_RESTORE, $hMsg[1]) Else ; Non-error. GUISetState(@SW_MAXIMIZE, $hMsg[1]) EndIf EndSwitch EndSwitch WEnd GUIDelete($hGUI1) #Region --- _WM_GETMINMAXINFO() Func _WM_GETMINMAXINFO($hWnd, $iMsg, $iwParam, $ilParam) #ForceRef $hWnd, $iMsg, $iwParam, $ilParam Switch $hWnd Case $hGUI1 Local $tagMINMAXINFO = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $ilParam) DllStructSetData($tagMINMAXINFO, 7, $___WINDOW_WIDTH_MIN) ; Min. X. DllStructSetData($tagMINMAXINFO, 8, $___WINDOW_HEIGHT_MIN) ; Min. Y. DllStructSetData($tagMINMAXINFO, 9, @DesktopWidth) ; Max. X. DllStructSetData($tagMINMAXINFO, 10, @DesktopHeight) ; Max. Y. ; ---------------------------------------------------------------------------------------------------- If BitAND(WinGetState($hWnd, ""), 32) = 32 Then GUICtrlSetTip($hGUI1_B5, "Restore main window to original position / size.", "RESTORE DOWN") Else ; Non-error. GUICtrlSetTip($hGUI1_B5, "Maximize main window to full screen.", "MAXIMIZE WINDOW") EndIf EndSwitch Return 0 EndFunc ;==>_WM_GETMINMAXINFO #EndRegion --- _WM_GETMINMAXINFO()How does it run for you? 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...
supersonic Posted February 23, 2013 Author Share Posted February 23, 2013 Melba23, thank you very much - again! It's the Xth time you helped me out! Greets, -supersonic. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 24, 2013 Moderators Share Posted February 24, 2013 supersonic, My pleasure as always. 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