I figured that the following code in mousemove would work:
Me.Left = X
Me.Top = Y
It is now obvious that left and top are not designed to handle this
situation, as the redraw is horrendous, and the form barely gets to
where my mouse is.
Does anyone have another suggestion?
Thank you very much,
Matt
Option Explicit
Private lRelOffsetLeft As Long
Private lRelOffsetTop As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Button = vbLeftButton Then
lRelOffsetLeft = X + Picture1.Left
lRelOffsetTop = Y + Picture1.Top
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Dim newLeft As Long
Dim newTop As Long
If Button = vbLeftButton Then
newLeft = (X + Me.Left + Picture1.Left) - lRelOffsetLeft
newTop = (Y + Me.Top + Picture1.Top) - lRelOffsetTop
Me.Move newLeft, newTop
End If
End Sub
<Matthe...@gmail.com> wrote in message
news:1137897866.8...@z14g2000cwz.googlegroups.com...
That's awesome! Smoooth...
Also thanks for the proper coding. I code very slopily.
The whole vbleftbutton thing will help me write up a context menu!
Any ideas on that?
Thanks,
Matt
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Button = vbLeftButton Then
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&
End If
End Sub
... and, if you want to drag the picturebox around the form, change the hwnd
...
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As
Single, Y As Single)
If Button = vbLeftButton Then
ReleaseCapture
SendMessage Picture1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&
End If
End Sub
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
Please reply to the newsgroups so all can participate.
<Matthe...@gmail.com> wrote in message
news:1137897866.8...@z14g2000cwz.googlegroups.com...
: So, I'm using mousedown to determine the mouse button is clock,
:
Lance
<Matthe...@gmail.com> wrote in message
news:1137909211.3...@o13g2000cwo.googlegroups.com...
Randy's solution solves my problem.
Thanks for all your help guys!
Matt
You will have to look up the API declarations...
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single,
y As Single)
On Error Resume Next
If Button = vbLeftButton Then
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
End If
End Sub
<Matthe...@gmail.com> wrote in message
news:1137897866.8...@z14g2000cwz.googlegroups.com...
Too bad Randy didn't think to post that same code (with the API
declarations) yesterday, huh?<g>
Rick