Imports System.Runtime.InteropServices
Public Class Form1
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, ByVal rectangle As RECT) As Boolean 'rectangle = receive handle's rectangle RECT,boolean = sucess or fail
Structure RECT
Dim x1 As Long
Dim y1 As Long
Dim x2 As Long
Dim y2 As Long
End Structure
<DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
Public Shared Function GetForegroundWindow() As IntPtr
End Function
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim r As RECT
Dim b As Boolean = GetWindowRect(GetForegroundWindow(), r) ’<- 这里exception
ListBox1.Items.Add(GetForegroundWindow.ToString & " - " & r.x1 & "," & r.y1 & " | " & r.x2 & "," & r.y2 & "(" & b & ")")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
欢迎光临 JBTALKS.CC (https://jbtalks.my/) | Powered by Discuz! X2.5 |