VERSION 5.00 Begin VB.Form Form1 Caption = "ウインドウの外側のサイズを取得するサンプル" ClientHeight = 870 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 870 ScaleWidth = 4680 StartUpPosition = 3 'Windows の既定値 Begin VB.CommandButton Command1 Caption = "実行" Height = 615 Left = 120 TabIndex = 0 Top = 120 Width = 4455 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False 'ウインドウの外側のサイズを取得する 'hWnd:ウインドウのハンドル 'lpRect:RECT構造体 '値はスクリーン座標なので注意 Private Declare Function GetWindowRect Lib "USER32" (ByVal hWnd As Long, lpRect As RECT) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Sub Command1_Click() Dim nRect As RECT Call GetWindowRect(Form1.hWnd, nRect) MsgBox "左上のx座標は" & nRect.Left & vbCrLf & _ "左上のy座標は" & nRect.Top & vbCrLf & _ "右下のx座標は" & nRect.Right & vbCrLf & _ "右下のy座標は" & nRect.Bottom End Sub