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:
Somebody any idea?
Greets,
-supersonic.
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:
[ autoit ]
#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.