在 vb6 中热制作鼠标在图像上离开事件

发布于 2024-09-13 12:06:38 字数 149 浏览 16 评论 0原文

我有一张图像,我在 MouseMove 中编写了代码来突出显示它。这是我想要的,当鼠标离开图像时,高光消失,但我似乎找不到任何可以做到这一点的事件。我正在使用 Visual Basic 6.0。我尝试过 mouseup 和 down 事件,但它们与我的要求不符。

谢谢

I have a image for which i have written code in MouseMove to higlight it. this is being done what i want is to when the mouse leaves image the highlights go away but i cant seem to find any event which will do that. i am working in visual basic 6.0. i have tried the mouseup and down event but they dont match my req.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

烟若柳尘 2024-09-20 12:06:38

VB6 中没有类似的事件(尽管 VB.Net 有 鼠标离开)。您将需要在窗体(或许还有任何容器控件)的 MouseMove 事件中执行某些操作。

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' Unhighlight the image'
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' Highlight the image'
End Sub

There isn't an event like that in VB6 (although VB.Net has MouseLeave). You will need to do something in the MouseMove event of the form (and perhaps any container controls too).

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' Unhighlight the image'
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' Highlight the image'
End Sub
痴者 2024-09-20 12:06:38

Marco Bellinaso 专门为此目的编写了一个很棒的小 ocx 控件,Marco Bellinaso 是一位受人尊敬的作者,也是当时 VB 社区优秀内容的重要贡献者。

该控件称为“MB MouseHelper”。您可以从 devx.com 下载它,网址为 http://www.devx.com/vb2themax/CodeDownload /19735

替代文本 http://img25.imageshack.us/img25/3985/screencap20100809110523.jpg< /a>

使用 VB 内置的 MouseMove 事件使该控件变得有用,有两个问题:

  • 您必须捕获用户在鼠标离开图像时可以放置鼠标的所有位置,例如表单或其他控件或附近的标签
  • 用户仍然可以非常快速地移动鼠标,跳过窗口的任何部分,从而触发 MouseMove 事件,从而取消突出显示图像

There is a great little ocx control for this exact purpose written by Marco Bellinaso, a well respected author and a big contributor of good content to the VB community in his time.

The control is called the "MB MouseHelper". You can download it from devx.com at http://www.devx.com/vb2themax/CodeDownload/19735.

alt text http://img25.imageshack.us/img25/3985/screencap20100809110523.jpg

There are two problems with using VB's built in MouseMove event that make this control useful:

  • You have to catch all the places where the user could put the mouse when it leaves your image, like the form or another control or a nearby label
  • And the user can still move the mouse very quickly, jumping over any part of the window that would trigger the MouseMove event that unhighlights your image
毁我热情 2024-09-20 12:06:38

您还可以将要模拟 mouseleave 事件的图像放在更大的图片中。这样,当您离开内部图片(较小)时,您将触发外部图片的 mousemove 事件。此外,如果您使用框架或标签而不是另一张图片,这也有效

You can also put the image you want to simulate the mouseleave event inside a bigger picture. That way, when you leave the inner picture (smaller) you will hit the mousemove event of the outer picture. Also, this works if you use a frame or label instead of another picture

冰葑 2024-09-20 12:06:38

您始终可以对控件进行子类化。 这里有一篇文章介绍了如何执行此操作。

You can always subclass the control. Here's an article that describes how to do it.

伴我心暖 2024-09-20 12:06:38

如果您使用 mouseMove 事件,需要注意的一件事是,当您处于要突出显示的控件中时,要升起一个标志,而当您处于 OUT 时,要升起另一个标志,以免在每次鼠标 xy 更改时重复相同的操作

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' if imageIsHighlighted = true then
  '    Unhighlight the image'
  '    imageIsHighlighted = false
  ' end if 
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' if imageIsHighlighted = false then
  '       Highlight the image'
  '       imageIsHighlighted = True
  ' end if 
End Sub

One thing to care about if you use the mouseMove event is to raise a flag when you are IN the control you want to highlight and raise another when you are OUT so as not to repeat the same action on each mouse xy change

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' if imageIsHighlighted = true then
  '    Unhighlight the image'
  '    imageIsHighlighted = false
  ' end if 
End Sub

Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  ' if imageIsHighlighted = false then
  '       Highlight the image'
  '       imageIsHighlighted = True
  ' end if 
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文