[RESOLVED] Move PictureBoxes to mouse position, anyone???
I am writing some source code, that I am required to have two graphic pictureboxes at two different mouse positons. And they are: X and Y.
Here is my source code, which only has the problem in it:
Code:
Public Sub BackGround1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Y < 0) Or (Y > ScaleHeight) Then
If (X < 0) Or (X > ScaleWidth) Then
If GetCapture() Then ReleaseCapture
Else
If Not GetCapture() Then SetCapture Me.hwnd
Form11.TopCursor1.Move Y
Form11.LeftCursor1.Move X
End If
End If
End Sub
Re: Move PictureBoxes to mouse position, anyone???
Quote:
Originally Posted by
ThEiMp
I am writing some source code, that I am required to have two graphic pictureboxes at two different mouse positons. And they are: X and Y.
Not sure what you mean by that. Also, one position is determined by X *and* Y coordinates. So to have two you'd have to have (x1, y1) and (x2, y2).
Re: Move PictureBoxes to mouse position, anyone???
Well I am moving a ruler marker into place. One is X and the other one is Y.
Can you please show me the code, to do so???
Really need this. Have been looking on the Internet and this Forum for help, and have come up against nothing much. But that source code, from one of the old threads, on this Forum.
This code seems to be working, but it must be optimised to run at lower cpu usage rates.
Code:
Public Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Y < 0) Or (X < 0) Or (Y > ScaleHeight) Or (X > ScaleWidth) Then
If GetCapture() Then ReleaseCapture
Else
If Not GetCapture() Then SetCapture Me.hwnd
Form11.TopCursor1.Move X
Form11.LeftCursor1.Move Y
End If
End Sub
Re: Move PictureBoxes to mouse position, anyone???
Put two lines on the form (lnLeft and lnTop) and use this code. Try to understand the code, this is extremely simple.
Code:
Option Explicit
Private Sub Form_Load()
lnLeft.X1 = 0
lnLeft.X2 = 120
lnLeft.Y1 = 0
lnLeft.Y2 = 0
lnTop.Y1 = 0
lnTop.Y2 = 120
lnTop.X1 = 0
lnTop.X2 = 0
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
lnLeft.Y1 = Y
lnLeft.Y2 = Y
lnTop.X1 = X
lnTop.X2 = X
End Sub
Re: Move PictureBoxes to mouse position, anyone???
The code that you had placed on this thread, worked just fine!!
Thanks for the help!!