[..] Fixer des limites Minimum et Maximum

Aide sur les Interfaces Graphique Utilisateurs (GUI).
Règles du forum
.
Répondre
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

[..] Fixer des limites Minimum et Maximum

#1

Message par Anthony »

Bonjour à tous,

Je souhaiterai fixer des limites Minimum et Maximum au "Bloc-notes" de Windows MIN_W, MIN_H, MAX_W, MAX_H: (160, 120, 640, 480) .
J'ai pensé à _GUI_RESIZE_SET_MIN_MAX($iPID, 160, 120, 640, 480) mais je n'arrive pas à injecter la fonction au "Bloc-notes"
Avez-vous une idée les amis.
Merci ;)
$hGUI = GUICreate("Test", 320, 200, -1, -1, 0x00040000)
GUISetState()

Local $iPID    = Run("notepad.exe", "")
Local $Handle  = WinWaitActive("[CLASS:Notepad]")

ConsoleWrite($Handle &" "&$iPID& @CRLF)

_GUI_RESIZE_SET_MIN_MAX(160, 120, 640, 480)     ; Je souhaiterai envoyer la fonction sur "notepad.exe" par: _GUI_RESIZE_SET_MIN_MAX($iPID, 160, 120, 640, 480)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
    EndSwitch
WEnd

Func _GUI_RESIZE_SET_MIN_MAX( $MIN_W, $MIN_H, $MAX_W, $MAX_H)
   Global $GUI_MIN_W = $MIN_W
   Global $GUI_MIN_H = $MIN_H
   Global $GUI_MAX_W = $MAX_W
   Global $GUI_MAX_H = $MAX_H
   GUIRegisterMsg(0x0024, "_WM_GETMINMAXINFO")
EndFunc

Func _WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam)
    $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
    DllStructSetData($tagMaxinfo, 7, $GUI_MIN_W) ; min X
    DllStructSetData($tagMaxinfo, 8, $GUI_MIN_H) ; min Y
    DllStructSetData($tagMaxinfo, 9, $GUI_MAX_W ); max X
    DllStructSetData($tagMaxinfo, 10, $GUI_MAX_H ) ; max Y
    Return 0
EndFunc   ;==>WM_GETMINMAXINFO


;~    ConsoleWrite($WinGetHandle &" "&$iPID&" "&$hGUI &" "& $hwnd &" "& $Msg &" "& $wParam &" "& $lParam & @CRLF)
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Avatar du membre
walkson
Modérateur
Modérateur
Messages : 1020
Enregistré le : ven. 12 août 2011 19:49
Localisation : Hurepoix
Status : Hors ligne

Re: [..] Fixer des limites Minimum et Maximum

#2

Message par walkson »

Bonjour,
Une méthode qui vient du forum us (AZJIO) mais en russe (les ? sont du russe que scite ne traduit pas..)
Global $k=0
$Gui = GUICreate("?????? ?????? ????, ????????????", 390, 140, -1, -1, 0x00040000+0x00020000+0x00010000)
GUICtrlCreateLabel('??????? WM_GETMINMAXINFO ??????????? ?? ????? ??????????? ????, ???????????? ? ????????? ????????. ????????? ?????????? ??????? ?????????? ? ?????????? ???? ??? ?? ??????????? ??? ? ?? ????????? ?????????????. ? ????? ??????? ? ??????? ???????????? ?????????. ???????????? ????????? ????? ???????????? ?????? ?????? ??????????? ?????????.', 5, 5, 360, 130)

GUISetState()

GUIRegisterMsg(0x0024, "WM_GETMINMAXINFO")

Do
Until GUIGetMsg() = -3

Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
   $k+=1
   WinSetTitle($Gui, '', '??????? ' &$k& ' ???')
   #forceref $iMsg, $wParam
   If $hWnd = $GUI Then
      Local $tMINMAXINFO = DllStructCreate("int;int;" & _
            "int MaxSizeX; int MaxSizeY;" & _
            "int MaxPositionX;int MaxPositionY;" & _
            "int MinTrackSizeX; int MinTrackSizeY;" & _
            "int MaxTrackSizeX; int MaxTrackSizeY", _
            $lParam)
      DllStructSetData($tMINMAXINFO, "MinTrackSizeX", 360) ; ??????????? ??????? ????
      DllStructSetData($tMINMAXINFO, "MinTrackSizeY", 130)
      DllStructSetData($tMINMAXINFO, "MaxTrackSizeX", 460) ; ???????????? ??????? ????
      DllStructSetData($tMINMAXINFO, "MaxTrackSizeY", 180)
      DllStructSetData($tMINMAXINFO, "MaxSizeX", 400) ; ??????? ???????????? ????????? ( ?????? ????? ??????, ???? ???????????? ????????)
      DllStructSetData($tMINMAXINFO, "MaxSizeY", 180)
      DllStructSetData($tMINMAXINFO, "MaxPositionX", 400) ; ??????? ? ??????????? ?????????
      DllStructSetData($tMINMAXINFO, "MaxPositionY", 450)
   EndIf
EndFunc
Une autre méthode qui vient de Guiness
#include <WinAPIEx.au3> ; Search the Examples forum.

Global $aArray, $hHandle, $iPID

$iPID = Run('Notepad.exe')
$aArray = _WinAPI_EnumProcessWindows($iPID)
If @error Then
    Exit
EndIf
$hHandle = $aArray[1][0]

While 1
    If ProcessExists($iPID) = 0 Then
        ExitLoop
    EndIf

    $aArray = WinGetPos($hHandle)
    If $aArray[2] < 160 Then
        WinMove($hHandle, '', $aArray[0], $aArray[1], 640, $aArray[3])
    EndIf
    If $aArray[2] > 640 Then
        WinMove($hHandle, '', $aArray[0], $aArray[1], 640,$aArray[3])
    EndIf
    If $aArray[3] < 120 Then
        WinMove($hHandle, '', $aArray[0], $aArray[1],  $aArray[2],480)
    EndIf
    If $aArray[3] > 480 Then
        WinMove($hHandle, '', $aArray[0], $aArray[1], $aArray[2], 480)
    EndIf
    Sleep(100) ; Reduce CPU.
WEnd
Cordialement,
Walkson
"Horas non numero nisi serenas " Le canon de midi
(Je ne compte que les heures heureuses)
Avatar du membre
Anthony
Niveau 6
Niveau 6
Messages : 292
Enregistré le : lun. 17 janv. 2011 14:08
Localisation : France
Status : Hors ligne

Re: [..] Fixer des limites Minimum et Maximum

#3

Message par Anthony »

Merci walkson désolé pour le retour tardif, je fais des travaux dans la maison et çà prends pas mal de temps...
C'est déjà un bon début, c'est bizarre qu'un UDF ne soit pas sorti pour cette fonction... i'm waiting...
Merci ;)
J'ai été diagnostiqué pour trouble de la concentration, soyez indulgent
Merci à tous pour votre aide.

Mon UDF GuiStatusBar facile
Répondre