VB鼠标事件的编程题目
在窗体上画一个文本框、一个图片框和一个命令按钮。编写程序,使得当鼠标光标位于不同的控件或窗体上时,鼠标光标具有不同的形状,此时如果按下鼠标右键,则显示相应的信息。例如,当...
在窗体上画一个文本框、一个图片框和一个命令按钮。编写程序,使得当鼠标光标位于不同的控件或窗体上时,鼠标光标具有不同的形状,此时如果按下鼠标右键,则显示相应的信息。例如,当鼠标光标移到图片框上时,如果按下鼠标右键,则用一个信息框显示“现在鼠标光标位于图片框中”。
要求:在文本框和窗体上的鼠标光标使用系统提供的光标形状,而图片框的命令按钮上的鼠标光标使用自定义的形状。 展开
要求:在文本框和窗体上的鼠标光标使用系统提供的光标形状,而图片框的命令按钮上的鼠标光标使用自定义的形状。 展开
2个回答
展开全部
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command1.MousePointer = vbCross
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
MsgBox "现在鼠标光标位于命令按钮中"
End If
End Sub
Private Sub Form_Load()
'Picture1.MouseIcon = LoadPicture("C:\hand.cur")'光标文件的路径
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.MousePointer = vbDefault
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
MsgBox "现在鼠标光标位于窗体上"
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.MousePointer = vbCustom
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
MsgBox "现在鼠标光标位于图片框中"
End If
End Sub
Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.MousePointer = vbHourglass
End Sub
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
MsgBox "现在鼠标光标位于文本框中"
End If
End Sub
Command1.MousePointer = vbCross
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
MsgBox "现在鼠标光标位于命令按钮中"
End If
End Sub
Private Sub Form_Load()
'Picture1.MouseIcon = LoadPicture("C:\hand.cur")'光标文件的路径
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.MousePointer = vbDefault
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
MsgBox "现在鼠标光标位于窗体上"
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.MousePointer = vbCustom
End Sub
Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
MsgBox "现在鼠标光标位于图片框中"
End If
End Sub
Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.MousePointer = vbHourglass
End Sub
Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbRightButton Then
MsgBox "现在鼠标光标位于文本框中"
End If
End Sub
展开全部
这。。。是vb?
鼠标光标怎么改我是不知道
但是你可以尝试用mousemove事件检测你的鼠标在哪个控件上
还有三个神奇的事件
mousedown
mouseclick
mouseup
你挨个试试看吧
鼠标光标怎么改我是不知道
但是你可以尝试用mousemove事件检测你的鼠标在哪个控件上
还有三个神奇的事件
mousedown
mouseclick
mouseup
你挨个试试看吧
追问
鼠标光标是mousepointer。关键是在某一控件单击鼠标右键显示信息,这个不知道怎么写?在那个事件过程写?
追答
之前我就说了我不知道怎么改光标,但你吧所有的控件都建立mousemove的事件
这样的话在图片上移动就检测到图片上有鼠标在移动,然后出发事件
如此如此这般这般
右键就mouseclick就可以做到了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询