1个回答
展开全部
在Picture1中放入两个Line控件(务必画在Picture控件内而不是窗体内),名字用默认的Line1、Line2。代码如下:
Private Sub Form_Load()
Line1.Visible = False
Line2.Visible = False
End Sub
Private Sub Picture1_DblClick()
Line1.Visible = Not Line1.Visible
Line2.Visible = Line1.Visible
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Line1.X1 = 0
Line1.X2 = Picture1.ScaleWidth
Line1.Y1 = Y
Line1.Y2 = Y
Line2.X1 = X
Line2.X2 = X
Line2.Y1 = 0
Line2.Y2 = Picture1.ScaleHeight
End Sub
追问
厉害的,还有个问题,我这是一个坐标系,我怎么能做到随着我鼠标的移动,在我这两条坐标轴上显示我当前鼠标位置所对应的坐标系数字(x,y值)
追答
可以再在Picture1中加入两个Label控件Label1、Label2(注意事项同上):
Private Sub Form_Load()
Line1.Visible = False
Line2.Visible = False
Label1.AutoSize = True
Label2.AutoSize = True
Label1.Visible = False
Label2.Visible = False
End Sub
Private Sub Picture1_DblClick()
Line1.Visible = Not Line1.Visible
Line2.Visible = Line1.Visible
Label1.Visible = Line1.Visible
Label2.Visible = Line1.Visible
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Line1.X1 = 0
Line1.X2 = Picture1.ScaleWidth
Line1.Y1 = Y
Line1.Y2 = Y
Line2.X1 = X
Line2.X2 = X
Line2.Y1 = 0
Line2.Y2 = Picture1.ScaleHeight
Label1.Caption = X
Label1.Move X, 0
Label2.Caption = Y
Label2.Move 0, Y
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询