Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Label1.Left = X + 100 Label2.Left = X + 100 Label1.Top = Y Label2.Top = Y + 200 Label1.Caption = "X=" & X Label2.Caption = "Y=" & Y End Sub
[解决办法] 突然发现,我怎么这么笨啊........ 我改了下,有个问题,有时鼠标移出了picturebox,可label1依然在图片框中显示,怎么让它当鼠标移出picturebox时隐藏?我写的代码如下(窗体和图片框ScaleMode属性为3-pixel): Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Label1.Left = X Label1.Top = Y - 10 Label1.Caption = Str(X) + "," + Str(Y) End Sub [解决办法]
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Label1.Visible = False Label2.Visible = False End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Label1.Visible = True Label2.Visible = True Label1.Left = X + 100 Label2.Left = X + 100 Label1.Top = Y Label2.Top = Y + 200 Label1.Caption = "X=" & X Label2.Caption = "Y=" & Y End Sub
[解决办法] 谢谢zdingyun了,受教了~~~ 现在利用你的方法我写了一个程序,想在图片框中移动时显示鼠标的坐标,同时鼠标在图片框中单击获得几个点,并连起来形成一条折线,不知道为什么鼠标在图片框中移动能显示坐标,但单击时就是不画直线,是不是当鼠标在图片框中时一直在执行Picture1_MouseMove事件而Picture1_MouseDown事件没有执行?这要怎么解决?本来想等这个实现了还想做一下选中折线中的某个顶点,拖动这个顶点,同时显示变化的折线,看来不简单.... 这是我写的代码,望指正~! Dim a(10) As Integer, b(10) As Integer Dim t As Integer
Private Sub Form_Load() t = 0 End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Label1.Visible = False End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Picture1.Cls a(t) = X: b(t) = Y t = t + 1 For i = 0 To t - 2 Picture1.Line (a(i), b(i))-(a(i + 1), b(i + 1)) Next
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Visible = True Label1.Left = X Label1.Top = Y - 10 Label1.Caption = Str(X) + "," + Str(Y) End Sub