GetWindowPlacement

機能
ウィンドウの位置・状態を取得
Declare Function GetWindowPlacement Lib "user32.dll" _
(ByVal hWnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Declare Function GetWindowPlacement Lib "user32.dll" _
(ByVal hWnd As Integer, lpwndpl As WINDOWPLACEMENT) As Integer

BOOL GetWindowPlacement(
HWND hWnd,
WINDOWPLACEMENT *lpwndpl
);
引数
hWnd

ウィンドウのハンドル
lpwndpl
(戻り値)情報を受け取るWINDOWPLACEMENT構造体
戻り値
正常終了のとき  0以外
エラーのとき  0
サンプル
ダウンロード(GetWindowPlacement.lzh 2.09KB)

Private Sub Command1_Click()
Dim lpwndpl As WINDOWPLACEMENT

'構造体のサイズ
lpwndpl.length = Len(lpwndpl)

'関数の実行
Call GetWindowPlacement(Me.hWnd, lpwndpl)

'表示
With lpwndpl
    Me.List1.Clear
    Me.List1.AddItem "Formの X,Y座標 と幅,高さの取得(単位:ピクセル)"
    Me.List1.AddItem ""
    Me.List1.AddItem "Left  :" + Str(.rcNormalPosition.Left)
    Me.List1.AddItem "Top   :" + Str(.rcNormalPosition.Top)
    Me.List1.AddItem "Width :" + Str(.rcNormalPosition.Right - .rcNormalPosition.Left)
    Me.List1.AddItem "Height:" + Str(.rcNormalPosition.Bottom - .rcNormalPosition.Top)
End With
End Sub