函数参考


_WinAPI_GetWindowPlacement

检索最小, 最大窗口与正常位置的布局

#Include <WinAPI.au3>
_WinAPI_GetWindowPlacement($hWnd)

参数

$hWnd 窗口句柄

返回值

成功: 返回布局坐标的 $tagWINDOWPLACEMENT 结构
失败: 0, @error = 1, @extended = _WinAPI_GetLastError()

注意/说明

None.

相关

_WinAPI_SetWindowPlacement, $tagWINDOWPLACEMENT

详情参考

在MSDN中搜索


示例/演示


#include <WinAPI.au3>

Local $hWnd, $iRET, $pStruct, $sMsg, $stRET

; Create an instance of notepad to play with
Run("notepad.exe")
$hWnd = WinWait("[CLASS:Notepad]")
WinMove($hWnd, "", 256, 256, 400, 400)
Sleep(1000)

; Minimize and then check the placement values returned by _WinAPI_GetWindowPlacement()
WinSetState($hWnd, "", @SW_MINIMIZE)
$stRET = _WinAPI_GetWindowPlacement($hWnd)
If @error = 0 Then
    $sMsg = "$stWindowPlacement:" & @CRLF & @CRLF
    $sMsg &= @TAB & "length = " & DllStructGetData($stRET, "length") & @CRLF
    $sMsg &= @TAB & "flags = " & DllStructGetData($stRET, "flags") & @CRLF
    $sMsg &= @TAB & "showCmd = " & DllStructGetData($stRET, "showCmd") & @CRLF & @CRLF
    $sMsg &= "ptMinPosition:" & @CRLF
    $sMsg &= @TAB & "MinX = " & DllStructGetData($stRET, "ptMinPosition", 1) & @CRLF
    $sMsg &= @TAB & "MinY = " & DllStructGetData($stRET, "ptMinPosition", 2) & @CRLF & @CRLF
    $sMsg &= "ptMaxPosition:" & @CRLF
    $sMsg &= @TAB & "MaxX = " & DllStructGetData($stRET, "ptMaxPosition", 1) & @CRLF
    $sMsg &= @TAB & "MaxY = " & DllStructGetData($stRET, "ptMaxPosition", 2) & @CRLF & @CRLF
    $sMsg &= "rcNormalPosition:" & @CRLF
    $sMsg &= @TAB & "left = " & DllStructGetData($stRET, "rcNormalPosition", 1) & @CRLF
    $sMsg &= @TAB & "top = " & DllStructGetData($stRET, "rcNormalPosition", 2) & @CRLF
    $sMsg &= @TAB & "right = " & DllStructGetData($stRET, "rcNormalPosition", 3) & @CRLF
    $sMsg &= @TAB & "bottom = " & DllStructGetData($stRET, "rcNormalPosition", 4)
    MsgBox(4160, "Success", $sMsg)

    ; Change the normalized rectangle with _WinAPI_SetWindowPlacement() and then restore
    DllStructSetData($stRET, "rcNormalPosition", 128, 1); left
    DllStructSetData($stRET, "rcNormalPosition", 128, 2); top
    DllStructSetData($stRET, "rcNormalPosition", @DesktopWidth - 128, 3); right
    DllStructSetData($stRET, "rcNormalPosition", @DesktopHeight - 128, 4); bottom
    $pStruct = DllStructGetPtr($stRET); Get pointer to the modified struct
    $iRET = _WinAPI_SetWindowPlacement($hWnd, $pStruct)
    If @error = 0 Then
        WinSetState($hWnd, "", @SW_RESTORE)
        ControlSetText($hWnd, "", "Edit1", "_WinAPI_SetWindowPlacement() succeeded!")
    Else
        MsgBox(16, "错误", "_WinAPI_SetWindowPlacement() failed!" & @CRLF & _
                "$iRET = " & $iRET & @CRLF & _
                "@error = " & @error & @CRLF & _
                "@extended = " & @extended)
    EndIf
Else
    MsgBox(16, "错误", "_WinAPI_GetWindowPlacement() failed!" & @CRLF & _
            "$stRET = " & $stRET & @CRLF & _
            "@error = " & @error & @CRLF & _
            "@extended = " & @extended)
EndIf