谁能告诉我下面这段VB程序执行什么功能,最好能解释一下控件?
程序如下:PrivateSubPicture1_MouseDown(ButtonAsInteger,ShiftAsInteger,XAsSingle,YAsSingle)...
程序如下:
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text2.SetFocus
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Label1_Click
End Sub 展开
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text2.SetFocus
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Label1_Click
End Sub 展开
3个回答
展开全部
Option Explicit
'声明API函数
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
'声明常量
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = &H2
Private Sub Label1_Click()
Debug.Print "Click"
End Sub
'*********************************
'下面这个MouseDown事件处理分开解释如过程中注释
'整个过程的目的就是,在Picture1上实现按下鼠标左键拖动来移动窗体的效果(一般无标题栏的窗体才会使用这种方式)
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then '如果是左键按下
Dim ReturnVal As Long
X = ReleaseCapture() '当前窗体释放鼠标捕获
ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0) '向当前窗体发送标题栏鼠标按下消息
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text2.SetFocus '如果回车键按下就将焦点设置到Text2上,激活Text2
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Label1_Click '如果是回车键按下就调用Label1的Click事件
End Sub
'声明API函数
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long
'声明常量
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = &H2
Private Sub Label1_Click()
Debug.Print "Click"
End Sub
'*********************************
'下面这个MouseDown事件处理分开解释如过程中注释
'整个过程的目的就是,在Picture1上实现按下鼠标左键拖动来移动窗体的效果(一般无标题栏的窗体才会使用这种方式)
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then '如果是左键按下
Dim ReturnVal As Long
X = ReleaseCapture() '当前窗体释放鼠标捕获
ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0) '向当前窗体发送标题栏鼠标按下消息
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text2.SetFocus '如果回车键按下就将焦点设置到Text2上,激活Text2
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Label1_Click '如果是回车键按下就调用Label1的Click事件
End Sub
展开全部
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text2.SetFocus '如果按键是enter,则text2得到焦点
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Label1_Click '如果按键是enter,则调用label1的click事件
第一段看不懂,呵呵
End Sub
If Button = 1 Then
Dim ReturnVal As Long
X = ReleaseCapture()
ReturnVal = SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End If
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text2.SetFocus '如果按键是enter,则text2得到焦点
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Label1_Click '如果按键是enter,则调用label1的click事件
第一段看不懂,呵呵
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼上答的很对了
不过我就是想说
如果不懂什么作用
就看那个函数名,比如: Picture1_MouseDown,Text1_KeyDown等
一看就知道第一个函数是发生在鼠标按下的过程中
第二,三个函数是发生在键盘按下的过程中
SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
获得句柄,一般是坐标移动的
if KeyCode = 13 Then Text2.SetFocus
指按下某键激活,例如tab键的作用~~~
就算不是很清楚具体细节,大概还是可以搞定的 ~哈哈
不过我就是想说
如果不懂什么作用
就看那个函数名,比如: Picture1_MouseDown,Text1_KeyDown等
一看就知道第一个函数是发生在鼠标按下的过程中
第二,三个函数是发生在键盘按下的过程中
SendMessage(hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
获得句柄,一般是坐标移动的
if KeyCode = 13 Then Text2.SetFocus
指按下某键激活,例如tab键的作用~~~
就算不是很清楚具体细节,大概还是可以搞定的 ~哈哈
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询