UDF > WinAPIEx > System > Windows >


_WinAPI_GetWindowPlacement

Obtient la position d'une fenêtre, Min, Max, et normale

#include <WinAPISysWin.au3>
_WinAPI_GetWindowPlacement ( $hWnd )

Paramètre

$hWnd Handle de la fenêtre

Valeur de retour

Succès: Retourne la structure $tagWINDOWPLACEMENT avec les coordonnées de position
Échec: Définit @error <>0, appelez _WinAPI_GetLastError() pour obtenir des informations sur l'erreur.

En relation

$tagWINDOWPLACEMENT, _WinAPI_SetWindowPlacement

Voir aussi

Consultez GetWindowPlacement dans la librairie MSDN.

Exemple

#include <MsgBoxConstants.au3>
#include <WinAPISysWin.au3>

Local $hWnd, $iRET, $sMsg, $tRET

; Crée une instance de bloc-notes pour jouer avec
Run("notepad.exe")
$hWnd = WinWait("[CLASS:Notepad]")
WinMove($hWnd, "", 256, 256, 400, 400)
Sleep(1000)

; Minimise puis contrôle les valeurs de placement retournées par _WinAPI_GetWindowPlacement()
WinSetState($hWnd, "", @SW_MINIMIZE)
$tRET = _WinAPI_GetWindowPlacement($hWnd)
If @error = 0 Then
    $sMsg = "$stWindowPlacement:" & @CRLF & @CRLF
    $sMsg &= @TAB & "length = " & DllStructGetData($tRET, "length") & @CRLF
    $sMsg &= @TAB & "flags = " & DllStructGetData($tRET, "flags") & @CRLF
    $sMsg &= @TAB & "showCmd = " & DllStructGetData($tRET, "showCmd") & @CRLF & @CRLF
    $sMsg &= "ptMinPosition:" & @CRLF
    $sMsg &= @TAB & "MinX = " & DllStructGetData($tRET, "ptMinPosition", 1) & @CRLF
    $sMsg &= @TAB & "MinY = " & DllStructGetData($tRET, "ptMinPosition", 2) & @CRLF & @CRLF
    $sMsg &= "ptMaxPosition:" & @CRLF
    $sMsg &= @TAB & "MaxX = " & DllStructGetData($tRET, "ptMaxPosition", 1) & @CRLF
    $sMsg &= @TAB & "MaxY = " & DllStructGetData($tRET, "ptMaxPosition", 2) & @CRLF & @CRLF
    $sMsg &= "rcNormalPosition:" & @CRLF
    $sMsg &= @TAB & "left = " & DllStructGetData($tRET, "rcNormalPosition", 1) & @CRLF
    $sMsg &= @TAB & "top = " & DllStructGetData($tRET, "rcNormalPosition", 2) & @CRLF
    $sMsg &= @TAB & "right = " & DllStructGetData($tRET, "rcNormalPosition", 3) & @CRLF
    $sMsg &= @TAB & "bottom = " & DllStructGetData($tRET, "rcNormalPosition", 4)
    MsgBox($MB_SYSTEMMODAL, "Succès", $sMsg)

    ; Modifie le rectangle normalisé avec _WinAPI_SetWindowPlacement() et puis restaure
    DllStructSetData($tRET, "rcNormalPosition", 128, 1); gauche
    DllStructSetData($tRET, "rcNormalPosition", 128, 2); haut
    DllStructSetData($tRET, "rcNormalPosition", @DesktopWidth - 128, 3); droite
    DllStructSetData($tRET, "rcNormalPosition", @DesktopHeight - 128, 4); bas
    $iRET = _WinAPI_SetWindowPlacement($hWnd, $tRET)
    If @error = 0 Then
        WinSetState($hWnd, "", @SW_RESTORE)
        ControlSetText($hWnd, "", "Edit1", "_WinAPI_SetWindowPlacement() a réussi!")
    Else
        MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_SetWindowPlacement() a échoué!" & @CRLF & _
                "$tRET = " & $tRET & @CRLF & _
                "@error = " & @error & @CRLF & _
                "@extended = " & @extended)
    EndIf
Else
    MsgBox($MB_SYSTEMMODAL, "Error", "_WinAPI_GetWindowPlacement() failed!" & @CRLF & _
            "$tRET = " & $tRET & @CRLF & _
            "@error = " & @error & @CRLF & _
            "@extended = " & @extended)
EndIf