Hier mein neuestes Werk:
Eine UDF, die euch das Management für Minimum/Maximum Size von resizeable Windows (Style: SIZEBOX/THICKFRAME) abnimmt.
Die UDF funktioniert auch nur mit GUI, die den korrekten Style haben. Andere werden ignoriert.
Die Anzahl der gleichzeitig zu handelnden GUI ist nicht limitiert.
Es können einzelne oder alle Parameter (min width/height, max width/height) berücksichtigt werden.
Wird ein Parameter auf 0 gesetzt, wird er beim Handling ignoriert. Mit -1 werden die aktuellen Größenwerte übernommen.
Zur Auswahl steht auch die Größe des Fensters oder des Clientbereiches zu verwenden.
Per Option ist wählbar, ob der Minimize-Button das Fenster verkleinert auf die registrierten Minimumwerte (Standard) oder das normale Systemverhalten genutzt wird (minimieren in die Taskbar).
Es gibt eine Funktion mit der alle Parameter auf einmal gesetzt werden können. Alternativ lassen sich einzelne Parameter setzen.
Beim Minimieren und Maximieren wird der bisherige Fenstermittelpunkt beibehalten. Würde dabei die Taskbar oder der Desktoprand überlappt werden, wird die Position automatisch angepasst.
Hier die Liste aller Funktionen, das gibt schon etwas Aufschluss.
_GuiMM_SetMinMax
Setzt die MinMax Parameter für ein Fenster und registriert es für das MinMax Handling, falls noch nicht mit anderer Funktion erfolgt.
_GuiMM_GetMinMax
Gibt ein Array zurück mit den Min/Max Einstellungen. [wMin, hMin, wMax, hMax, bMinimizeToMinSize, bModeWindow]
_GuiMM_Unregister
Entfernt ein Fenster vom MinMax Handling
----------------------------------------------------------------------------------------------------
"_GuiMM_SetMinMax" erlaubt das Setzen aller möglichen Parameter auf einmal.
Die folgenden Funktionen können genutzt werden um einzelne Parameter zu ändern.
_GuiMM_SetMin
Setzt die Minimum-Größe Parameter für ein Fenster und registriert es, falls noch nicht erfolgt
_GuiMM_SetMax
Setzt die Maximum-Größe Parameter für ein Fenster und registriert es, falls noch nicht erfolgt
_GuiMM_SetMinimizeToMin
Setzt das Verhalten des Minimize-Button. Minimieren zu: Minimum-Größe oder Taskbar
_GuiMM_SetWindowMode
Setzt das Min/Max Handling für Fenster- oder Clientgröße
----------------------------------------------------------------------------------------------------
Zum Debuggen:
_GuiMM_DebugRegister
Registriert Input-ID's zum Empfangen der aktuellen Fenster und/oder Client-Rectangle
Im angehängten Beispiel könnt ihr damit experimentieren.
----------------------------------------------------------------------------------------------------
Sets the MinMax parameters for a window and register this for MinMax handling, if not done with other function.
Returns an array with the min/max settings. [wMin, hMin, wMax, hMax, bMinimizeToMinSize, bModeWindow]
----------------------------------------------------------------------------------------------------
Sets the behaviour of the Minimize-Button. Minimize to: Minimium Size (True)/ Taskbar(False-Default)
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
Global $g_aGuiMinMax[100][9] = [[0]] ; [[counter],[hWnd,widthMin,heightMin,widthMax,heightMax,bMinimizeToMinSize,bMinimized,tCurrPos,bModeWindow], ..]
;===================================================================================================
; Null The already stored value will used. If not has done from User, the default value (0) will used.
;===================================================================================================
;===================================================================================================
; Description......: Sets the MinMax parameters for a window and register this for MinMax handling, if not done before.
; $_bMinimizeToMinSize The behaviour of the Minimize-Button. Minimize to: Minimium Size (True)/ Taskbar(False-Default)
;===================================================================================================
Func _GuiMM_SetMinMax($_hWnd, $_wMin=0, $_hMin=0, $_wMax=0, $_hMax=0, $_bMinimizeToMinSize=False, $_bModeWindow=False)
Local $aParam[] = [$_wMin, $_hMin, $_wMax, $_hMax, $_bMinimizeToMinSize, False, _WinAPI_GetWindowRect($_hWnd), $_bModeWindow]
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
;===================================================================================================
; Description......: For debugging: Registers input IDs to receive the current window and/or client size
;===================================================================================================
; [[counter],[hWnd,widthMin,heightMin,widthMax,heightMax,bMinimizeToMinSize,bMinimized,tCurrPos,bModeWindow], ..]
If $g_hMinMaxProc = Null Then $g_hMinMaxProc = DllCallbackRegister('__GuiMM_WinProc', 'ptr', 'hwnd;uint;wparam;lparam')
Return ($n = -1 ? SetError(2,0,0) : __GuiMM_UnRegister($n)) ; @error: a unregistered window cannot be removed
$g_aGuiMinMax[$_index][5] = $_aParam[4] = Null ? $g_aGuiMinMax[$_index][5] : $_aParam[4] ; bMinimizeToMinSize
$g_aGuiMinMax[$_index][6] = $_aParam[5] = Null ? $g_aGuiMinMax[$_index][6] : $_aParam[5] ; bMinimized
If ($_iMsg <> $WM_WINDOWPOSCHANGING And $_iMsg <> $WM_WINDOWPOSCHANGED And $_iMsg <> $WM_SYSCOMMAND) Then _
If $index = -1 Then Return _WinAPI_CallWindowProc($g_hMinMaxHook, $_hWnd, $_iMsg, $_iwParam, $_ilParam) ; default Window processing
If (Not $bMinimizeToMinSize) And $bMinimized Then ; now RESTORE, use size & pos from before minimized ($tCurrRect)
$tCurrRect.Left, $tCurrRect.Top, $tCurrRect.Right - $tCurrRect.Left, $tCurrRect.Bottom - $tCurrRect.Top, _
BitOR($SWP_FRAMECHANGED,$SWP_NOSENDCHANGING,$SWP_SHOWWINDOW)) ; prevents 1-time from WM_WINDOWPOSCHANGING
If $bMinimizeToMinSize Then ; none MINIMIZE, instead move window to minimal size with current center point
$g_aGuiMinMax[$index][6] = True ; $bMinimized, trigger to detect the RESTORE (next window msg is the restore msg)
Return _WinAPI_CallWindowProc($g_hMinMaxHook, $_hWnd, $_iMsg, $_iwParam, $_ilParam) ; default Window processing
Local $tWINDOWPOS = DllStructCreate("struct; HWND hwndInsertAfter;HWND hwnd;INT x;INT y;INT cx;INT cy;UINT flags; endstruct", $_ilParam)
Local $aMaxPos = __GuiMM_MaxPosCalc($wMax, $hMax, $iX_Wnd + Int($iW_Wnd/2), $iY_Wnd + Int($iH_Wnd/2))
Return _WinAPI_CallWindowProc($g_hMinMaxHook, $_hWnd, $_iMsg, $_iwParam, $_ilParam) ; default Window processing
; Try to use the same center point. If there is an overlap with the taskbar or desktop border, the position will be corrected
If WinExists($g_aGuiMinMax[$i][0]) Then _WinAPI_SetWindowLong($g_aGuiMinMax[$i][0], $GWL_WNDPROC, $g_hMinMaxHook)
;===================================================================================================
; Parameter(s).....: [optional] $_bReturnStruct - Rückgabe als (True) Struktur, (False - Standard) Array
;===================================================================================================
Local Const $ABM_GETAUTOHIDEBAR = 0x7 ; specify the cbSize and uEdge. Returns the handle to the autohide appbar
Local Const $ABS_ALWAYSONTOP = 0x2 ; ab Win7 nicht mehr!! --> wenn NICHT $ABS_AUTOHIDE ist es $ABS_ALWAYSONTOP
Local $hWndAppBar = DllCall("user32.dll", 'long', "FindWindowA", 'str', "Shell_traywnd", 'str', "")[0]
Local $tAPPBARDATA = DllStructCreate("dword cbSize;int hWnd;uint;uint uEdge;int left;int top;int right;int bottom;int")
Local $ret = DllCall($shell32, 'int', 'SHAppBarMessage', 'int', $ABM_GETTASKBARPOS, 'ptr', DllStructGetPtr($tAPPBARDATA))
$ret = DllCall($shell32, 'int', 'SHAppBarMessage', 'int', $ABM_GETSTATE, 'ptr', DllStructGetPtr($tAPPBARDATA))
$ret = DllCall($shell32, 'int', 'SHAppBarMessage', 'int', $ABM_GETAUTOHIDEBAR, 'ptr', DllStructGetPtr($tAPPBARDATA))
; return array or structure: [.hWnd, .autohide(True/False), .uEdge(0..3), .sEdge(left..bottom), .left, .top, .right, .bottom]
Local $aRet[] = [$hWndAppBar, ($iState = $ABS_AUTOHIDE), $iEdge, $aEdge[$iEdge], $tRC.left, $tRC.top, $tRC.right, $tRC.bottom]
Local $hGui1 = GUICreate('Test Min/Max [1]', 400, 300, -1, 60, BitOR($WS_SYSMENU, $WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_SIZEBOX))