今日主角:SetCapture、ReleaseCapture
API注解:
VB声明 | |
Declare Function SetCapture Lib "user32" Alias "SetCapture" (ByVal hwnd As Long) As Long | |
说明 | |
将鼠标捕获设置到指定的窗口。在鼠标按钮按下的时候,这个窗口会为当前应用程序或整个系统接收所有鼠标输入 | |
返回值 | |
Long,之前拥有鼠标捕获的窗口的句柄 | |
参数表 | |
参数 | 类型及说明 |
hwnd | Long,要接收所有鼠标输入的窗口的句柄 |
VB声明 |
Declare Function ReleaseCapture Lib "user32" Alias "ReleaseCapture" () As Long |
说明 |
为当前的应用程序释放鼠标捕获 |
返回值 |
Long,TRUE(非零)表示成功,零表示失败 |
实例代码:
Option Explicit '判断鼠标的Move
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long ' ')
Private Sub text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Text1
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
.Text = "里面"
ReleaseCapture
Else
.Text = "外面"
SetCapture .hWnd
End If
End With
Label1.Caption = "X: " & X
Label2.Caption = "Y: " & Y
End Sub
已经有(0)位网友发表了评论,你也评一评吧!
原创文章如转载,请注明:转载自Eddy Blog
原文地址:http://www.rrgod.com/program/306.html 欢迎订阅Eddy Blog。
Tags:VB SetCapture ReleaseCapture