Minimale größe des Fensters setzen

  • 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
    [autoit]

    #include <WindowsConstants.au3>
    #include <StructureConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIRichEdit.au3>

    [/autoit] [autoit][/autoit] [autoit]

    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];"

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $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

    [/autoit] [autoit][/autoit] [autoit]

    While 1

    [/autoit] [autoit][/autoit] [autoit]

    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    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

    [/autoit]

    Wäre für jede hilfe Dankbar.

    PS: Danke @progandy, durch dieses Beispiel verstehe ich jetzt das "$WM_SIZE". :thumbup:

    Einmal editiert, zuletzt von MehmeX (28. Juni 2009 um 22:08)

  • dies hier ist von Xeno

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $breite_min = 830
    $breite_max = 930
    $hoehe_min = 430
    $hoehe_max = 930

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("GUI", $breite_max, $hoehe_max, -1, -1, $WS_THICKFRAME)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()

    [/autoit] [autoit][/autoit] [autoit]

    Func MY_WM_GETMINMAXINFO($hWnd, $msg, $wParam, $lParam)
    $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $breite_min) ; min X
    DllStructSetData($minmaxinfo, 8, $hoehe_min) ; min Y
    DllStructSetData($minmaxinfo, 9, $breite_max) ; max X
    DllStructSetData($minmaxinfo, 10, $hoehe_max) ; max Y
    Return 0
    EndFunc ;==>MY_WM_GETMINMAXINFO

    [/autoit]
  • Wo wird das eingegeben, was ausgeführt werden soll, wenn man auf den OK-Button drückt?

    Script mit Testbutton:

    Spoiler anzeigen
    [autoit]


    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $breite_min = 150
    $breite_max = 300
    $hoehe_min = 175
    $hoehe_max = 350

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("GUI", $breite_max, $hoehe_max, -1, -1, $WS_THICKFRAME)
    GUICtrlCreateButton("ok", 5,5,40,20)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()

    [/autoit] [autoit][/autoit] [autoit]

    Func MY_WM_GETMINMAXINFO($hWnd, $msg, $wParam, $lParam)
    $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $breite_min) ; min X
    DllStructSetData($minmaxinfo, 8, $hoehe_min) ; min Y
    DllStructSetData($minmaxinfo, 9, $breite_max) ; max X
    DllStructSetData($minmaxinfo, 10, $hoehe_max) ; max Y
    Return 0
    EndFunc ;==>MY_WM_GETMINMAXINFO

    [/autoit]

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    k3mrwmIBHejryPvylQSFieDF5f3VOnk6iLAVBGVhKQegrFuWr3iraNIblLweSW4WgqI0SrRbS7U5jI3sn50R4a15Cthu1bEr

  • so gehts Alina

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    $breite_min = 150
    $breite_max = 300
    $hoehe_min = 175
    $hoehe_max = 350

    [/autoit] [autoit][/autoit] [autoit]

    GUICreate("GUI", $breite_max, $hoehe_max, -1, -1, $WS_THICKFRAME)
    $Button_1 = GUICtrlCreateButton("ok", 5, 5, 40, 20)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    GUIRegisterMsg($WM_GETMINMAXINFO, "MY_WM_GETMINMAXINFO")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $Button_1
    Run('Notepad.exe') ; Öffnet Notepad
    Case $msg = $GUI_EVENT_CLOSE
    Exit
    EndSelect
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func MY_WM_GETMINMAXINFO($hWnd, $msg, $wParam, $lParam)
    $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $breite_min) ; min X
    DllStructSetData($minmaxinfo, 8, $hoehe_min) ; min Y
    DllStructSetData($minmaxinfo, 9, $breite_max) ; max X
    DllStructSetData($minmaxinfo, 10, $hoehe_max) ; max Y
    Return 0
    EndFunc ;==>MY_WM_GETMINMAXINFO

    [/autoit]
  • Danke für eure schnellen Antworten. Könnte mir vielleicht jemand noch den Hintergrund für den folgenden Code erklären? Wäre nett, danke.

    Spoiler anzeigen
    [autoit]

    Func MY_WM_GETMINMAXINFO($hWnd, $msg, $wParam, $lParam)
    $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $breite_min) ; min X
    DllStructSetData($minmaxinfo, 8, $hoehe_min) ; min Y
    DllStructSetData($minmaxinfo, 9, $breite_max) ; max X
    DllStructSetData($minmaxinfo, 10, $hoehe_max) ; max Y
    Return 0
    EndFunc ;==>MY_WM_GETMINMAXINFO

    [/autoit]
  • Das hier hätte ich auch gerne gewusst:

    [autoit]

    $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $breite_min) ; min X
    DllStructSetData($minmaxinfo, 8, $hoehe_min) ; min Y
    DllStructSetData($minmaxinfo, 9, $breite_max) ; max X
    DllStructSetData($minmaxinfo, 10, $hoehe_max) ; max Y

    [/autoit]

    Z.B. die int's.
    Ich kenne mich noch nicht so gut mit Dll's aus. Auch die Hilfe bringt mich nicht auf hochtouren.

  • Achso, OK danke. :) Eine letzte Frage - Nur mit Fragen kommt man weiter - wieso ausgerechnet die 7, 8, 9, 10?

  • Wenn man die Struktur in die Ints übersetzt:

    Spoiler anzeigen

    POINT ptReserved;
    POINT ptMaxSize;
    POINT ptMaxPosition;
    POINT ptMinTrackSize;
    POINT ptMaxTrackSize;
    ... Int Nummer:
    1,2: Reserved
    3: MaxSize X
    4: MaxSize Y
    5: MaxPosition X
    6: MaxPosition Y
    7: MinTrackSize X
    8: MinTrackSize X
    9: MaxTrackSize X
    10: MaxTrackSize Y

    Du kannst das auch so machen:

    [autoit]

    $minmaxinfo = DllStructCreate("int ptReserved[2]; int ptMaxSize[2]; int ptMaxPosition[2]; int ptMinTrackSize[2]; int ptMaxTrackSize[2];", $lParam)
    DllStructSetData($minmaxinfo, "ptMinTrackSize", $breite_min, 1) ; min X
    DllStructSetData($minmaxinfo, "ptMinTrackSize", $hoehe_min, 2) ; min Y
    DllStructSetData($minmaxinfo, "ptMaxTrackSize", $breite_max, 1) ; max X
    DllStructSetData($minmaxinfo, "ptMaxTrackSize", $hoehe_max, 2) ; max Y

    [/autoit]
  • Hey Leute habe gerade ein Problem festgestellt und zwar werden alle anderen Fenster beim veschieben des Fensters auf die minimale Größe verändert, auch wenn das Fenster kleiner ist als die Minimale größe die festgelegt worden ist.

    Bitte um Hilfe!!!

  • Kann mir dabei keiner helfen?
    Denn alle anderen Fenster die kleiner von der größe sind als die minimale Fenster größe, werden beim verschieben der Position der Fenstern, auf die größe des Minimalen festgelegte Größe verändert. Das heißt, ich möchte die Minimale größe beim ziehen des Fensters, nur für das Hauptfenster.

    Edit: Tut mir leid wegen die Doppelposts, aber ich brauche unbedingt hilfe.

    Einmal editiert, zuletzt von MehmeX (30. Juni 2009 um 23:19)

  • Dann frag in der Funktion die GUI ab, für die die MinMaxInfo geholt wird:

    [autoit]

    Func MY_WM_GETMINMAXINFO($hWnd, $msg, $wParam, $lParam)
    If $hWnd = $dieHauptGUI Then
    $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($minmaxinfo, 7, $breite_min) ; min X
    DllStructSetData($minmaxinfo, 8, $hoehe_min) ; min Y
    DllStructSetData($minmaxinfo, 9, $breite_max) ; max X
    DllStructSetData($minmaxinfo, 10, $hoehe_max) ; max Y
    Return 0
    EndIf
    Return 'GUI_RUNDEFMSG' ; $GUI_RUNDEFMSG
    EndFunc ;==>MY_WM_GETMINMAXINFO

    [/autoit]
  • Hey sorry fürs ausgraben.
    Aber ich nutze die WM_GETMINMAXINFO auch. Wenn ich bei GUICreate 600x400 angebe und in der Func als MinX und MinY auch, kann ich trotzdem das Fenster noch kleiner ziehen bis zu einem Punkt. In Y ungefähr 33 Pixel und in X 5.
    Woran kann das liegen?