Hallo AutoIt-Leute,
habe eine Frage und zwar, wie kann ich die Minimale größe des Fensters setzen? Progandy hat zwar mal ein Beispiel geschrieben, nur kapiere ich das nicht so ganz und wollte fragen ob es eine Alternative gibt.
Hier das Beispiel von @progandy.
Spoiler anzeigen
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIRichEdit.au3>
Global $OLDPOSWINDOW
Global Const $WM_EXITSIZEMOVE = 0x0232
Global Const $tagMINMAXINFO = "int ptReserved[2]; int ptMaxSize[2]; int ptMaxPosition[2]; int ptMinTrackSize[2]; int ptMaxTrackSize[2];"
$hGUI = GUICreate("Test", 400, 400,-1,-1,$GUI_SS_DEFAULT_GUI+$WS_THICKFRAME)
[/autoit] [autoit][/autoit] [autoit]$hRichEdit = _GUICtrlRichEdit_Create($hGUI, 10, 10, 300, 300)
[/autoit] [autoit][/autoit] [autoit]GUISetState()
GUIRegisterMsg($WM_SIZE, "WM_SIZEPROC") ; Message für Größenänderungen
GUIRegisterMsg($WM_EXITSIZEMOVE, "WM_SIZEPROC") ; Message nach der Größenändernung
GUIRegisterMsg($WM_GETMINMAXINFO, "WM_SIZEPROC") ; Minimale Größe festlegen
While 1
[/autoit] [autoit][/autoit] [autoit]Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
[/autoit] [autoit][/autoit] [autoit]Func WM_SIZEPROC($hWnd, $uMsg, $wParam, $lParam)
Switch $uMsg
Case $WM_GETMINMAXINFO ; Die Fenstergröße abfragen, minimale Größe fürs verkleinern setzen
Local $MinMax = DllStructCreate($tagMINMAXINFO, $lParam) ; DLLStruct auf den Pointer erstellen, zum bearbeiten der Werte
DllStructSetData($MinMax, 4, 200, 1) ; Minimal 200 Pixel breit
DllStructSetData($MinMax, 4, 150, 2) ; Minimal 150 Pixel hoch
Case $WM_EXITSIZEMOVE ; nach dem ziehen
$OLDPOSWINDOW = 0 ; die gespeicherte Größe löschen
Case $WM_SIZE ; hier wird das RichEdit angepasst
Local $PosNeuAr[2] = [BitAND($lParam,0xFFFF), BitAND(BitShift($lParam,16),0xFFFF)] ; Die Breite und Höhe des Fensters auslesen, Lo-und HiWord vom lparam.
If IsArray($OLDPOSWINDOW) Then
Local $ControlPos = ControlGetPos($hRichEdit,"","")
; Möglichkeit 1: absolute Größenändernung:
ControlMove($hRichEdit,"","",$ControlPos[0],$ControlPos[1],$ControlPos[2]+$PosNeuAr[0]-$OLDPOSWINDOW[0],$ControlPos[3]+$PosNeuAr[1]-$OLDPOSWINDOW[1])
; Möglichkeit 2: relative Größenändernung (funktioniert nicht richtige)
;ControlMove($hRichEdit,"","",$ControlPos[0],$ControlPos[1],Int($ControlPos[2]*($PosNeuAr[0]/$OLDPOSWINDOW[0])),Int($ControlPos[3]*($PosNeuAr[1]/$OLDPOSWINDOW[1])))
EndIf
Global $OLDPOSWINDOW = $PosNeuAr ; Position für Neuberechnung speichern
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Wäre für jede hilfe Dankbar.
PS: Danke @progandy, durch dieses Beispiel verstehe ich jetzt das "$WM_SIZE".