Window の座標を取得する (GetWindowRect)
user32.dll の GetWindowRect を用いて、Window の座標を取得します。
サンプルのダウンロード
■サンプルの説明

プログラムが開始すると、こんな画面が立ち上がります。

取得 を押下するとこのようなメッセージが表示されます。
■コード
F0005_FlashWindowEx.vb
Imports System.Runtime.InteropServices ''' <summary> ''' FlashWindow(user32.dll) ''' </summary> Partial Public Class F0005_FlashWindowEx ''' <summary> ''' GetWindowRect(Window の位置等を取得)の宣言 ''' </summary> <DllImport("user32.dll", CharSet:=CharSet.Auto)> _ Private Shared Function GetWindowRect(ByVal hWnd As IntPtr, _ ByRef lpRect As RECT) _ As Boolean End Function ''' <summary> ''' RECT 構造体 ''' </summary> Private Structure RECT Public Left As Integer Public Top As Integer Public Right As Integer Public Bottom As Integer End Structure ''' <summary> ''' ロード時のイベント ''' </summary> Private Sub F0006_GetWindowRect_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Me.Text = "F0006_GetWindowRect" Me.FormBorderStyle = Windows.Forms.FormBorderStyle.Sizable Me.Button1.Text = "取得" End Sub ''' <summary> ''' 取得ボタンクリック時のイベント ''' </summary> Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim lpRect As RECT '取得 GetWindowRect(Me.Handle, lpRect) Dim buff As System.Text.StringBuilder buff = New System.Text.StringBuilder buff.Append("このフォームの現在の座標値" + ControlChars.NewLine) buff.Append("Top : " + lpRect.Top.ToString() + ControlChars.NewLine) buff.Append("Left : " + lpRect.Left.ToString() + ControlChars.NewLine) buff.Append("Bottom : " + lpRect.Bottom.ToString() + ControlChars.NewLine) buff.Append("Right : " + lpRect.Right.ToString()) MessageBox.Show(buff.ToString(), _ Me.Text, _ MessageBoxButtons.OK, _ MessageBoxIcon.Information) End Sub End Class