用易语言开发 精易模块 用鼠标取窗口句柄
时间: 2024-03-03 14:49:41 浏览: 194
以下是用易语言开发精易模块用鼠标取窗口句柄的代码:
```
'声明精易模块
Declare Module "user32.dll"
Function WindowFromPoint(ByVal x As Long, ByVal y As Long) As Long
End Declare
'窗口句柄
Dim hWnd As Long
'鼠标点击事件
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'获取鼠标所在位置对应的窗口句柄
hWnd = WindowFromPoint(X, Y)
End Sub
'鼠标移动事件
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'如果有窗口句柄
If hWnd <> 0 Then
'显示窗口句柄
Label1.Caption = "窗口句柄:" & hWnd
End If
End Sub
'鼠标松开事件
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'清空窗口句柄
hWnd = 0
Label1.Caption = ""
End Sub
```
这段代码和前面用易语言开发用鼠标取窗口句柄的代码实现方法相同,只不过使用了精易模块来声明WindowFromPoint函数。需要注意的是,使用精易模块需要在代码的开头声明该模块。
阅读全文