Option Strict Off Option Explicit On Friend Class Form1 Inherits System.Windows.Forms.Form ' ' Text1.MultiLine = True(複数行) ' .ScrollBar = 3 (両方) にしておくこと ' Const ME_TITLE As String = "リストビューの文字列取得" Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load Me.Text = ME_TITLE Command1.Text = "開始" Label1.Text = "" Text1.Text = "" Me.TopMost = True End Sub Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click Dim LoopSw As Boolean Dim Rc As Long Dim hWndPoint As Integer 'ポイント位置のウィンドウハンドル Dim hWndOld As Integer '過去のウィンドウハンドル Dim x As Integer, y As Integer 'マウスポインタ座標 Dim strClassName As String = "" 'クラス名 Command1.Enabled = False 'コマンドボタンを無効 Me.Text = "ESCで停止" GetAsyncKeyState(VK_ESCAPE) 'ダミー LoopSw = True Do x = System.Windows.Forms.Cursor.Position.X y = System.Windows.Forms.Cursor.Position.Y hWndPoint = WindowFromPoint(x, y) 'ポインタ位置のウィンドウハンドル If hWndPoint <> hWndOld Then 'ウィンドウハンドルが変化? hWndOld = hWndPoint 'ウィンドウハンドル保存 strClassName = MyGetClassName(hWndPoint) 'クラス名 Label1.Text = strClassName If InStr(strClassName, WC_LISTVIEW) > 0 Then Text1.Text = MyGetListViewItem(hWndPoint) Else Text1.Text = "" End If End If System.Threading.Thread.Sleep(10) '10ミリ秒待ち System.Windows.Forms.Application.DoEvents() Rc = GetAsyncKeyState(VK_ESCAPE) 'ESCキーが押されたか? If (Rc And 1) <> 0 Then LoopSw = False '押されている→ループオフ Loop While LoopSw Command1.Enabled = True 'コマンドボタンを有効 Me.Text = ME_TITLE End Sub Private Sub Form1_FormClosing(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing End End Sub End Class