我可能只是以这种错误的方式去做,我不知道。我有一个PNG,它是1000x1000像素。我的形状像五角大楼,每个部分都有一个盒子。我想要做的就是将每个作为PNG一部分的框都设置为可点击的框。我试图研究如何做到这一点,但我找不到这个问题的任何答案。先谢谢你。创建图像热点
创建图像热点
回答
您应该可以通过点击png时检查鼠标事件参数来完成此操作。
http://msdn.microsoft.com/en-us/library/system.windows.forms.mouseeventargs.aspx
Here是事件参数,以及如何将它们传递给函数或子程序的教程。
我相信this正是你正在尝试做的...
Private Sub PictureBox1_MouseDown(_
ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles PictureBox1.MouseDown
Dim myPicBox As PictureBox = sender
Select Case e.Y/myPicBox.Height
Case Is > 2/3
Debug.WriteLine("It's in the bottom third")
Case Is > 1/3
Debug.WriteLine("It's in the middle third")
Case Else
Debug.WriteLine("It's in the top third")
End Select
End Sub
引用的最后一个网站。
谢谢!我会尽力实施这个ASAP – user1124585
您可以处理MouseMove
事件和MouseDown
或MouseClick
活动,并检查Cursor
是一定的矩形内使用contains方法是这样的。它需要扩展以处理多个热点。
Public Class Form1
Dim hotspot1 As Rectangle = New Rectangle(25, 25, 50, 50)
Private Sub PictureBox1_MouseClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
If hotspot1.Contains(e.X, e.Y) Then
Beep()
End If
End Sub
Private Sub PictureBox1_MouseMove(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If hotspot1.Contains(e.X, e.Y) Then
If Cursor <> Cursors.Hand Then Cursor = Cursors.Hand
Else
If Cursor <> Cursors.Default Then Cursor = Cursors.Default
End If
End Sub
End Class
谢谢马克,这对我所需要的更精确。我试图找出一种方法来“切入”PNG,它根本不适合我。 – user1124585
@ user1124585很高兴为您提供帮助 –
- 1. 如何创建热点的图像
- 2. 使用数据点创建“热图像”
- 3. jquery图像热点
- 4. 创建动画热点/图像地图的最佳方法
- 5. 无法创建热点
- 6. Html图像热点切换图像
- 7. 图像热点变焦
- 8. 热点上的图像
- 9. 使用Tableau创建热图
- 10. 用Heatmap创建热图2
- 11. Angular 4 - 创建热图表
- 12. 热点名称没有更新热点创建欲望
- 13. 使用Yii2上下图创建热图
- 14. 从折线图创建一维热图
- 15. NEHotspotConfigurationManager不创建/加入热点
- 16. 如何用php创建动态热点?
- 17. PHP和Bash创建一个热点
- 18. Android 4.0.3创建wifi热点API
- 19. 创建随机发票热成像仪
- 20. 使用JavaScript和PHP创建图像中的活动区域(热点)
- 21. 从热图像中提取斑点值
- 22. 如何检测图像中的热点
- 23. 如何创建在c#中的eyetracking点的热图
- 24. 如何在图像上创建热链接?
- 25. 用热图创建边栏.2
- 26. 如何为此热图创建矩阵?
- 27. 从(x,y)中创建热图在R
- 28. 在Grafana中创建日/小时热图
- 29. 在SAS中创建热图使用
- 30. 如何创建特定的热图?
这是vba还是vb.net? –
我是visual studio 2010,并创建一个视觉基本的Windows应用程序。 – user1124585