drag window using image

how do I drag a window (form) by clicking and dragging on an image?
I have set the borderstyle to none and mimic'd topbar with an image, but now I can't drag (obviously).  How do i make the image (looks just like a normal titlebar with the X on it) drag the entire window?
thx in advance!
Bear
LVL 1
LosBearAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DeAnCommented:
assumes a picturebox name Picture1

Option Explicit

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 Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1

Private Const WM_SYSCOMMAND = &H112
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    ReleaseCapture
    SendMessage hwnd, WM_NCLBUTTONDOWN, _
        HTCAPTION, 0&

    ' Or use:
'    SendMessage hwnd, WM_SYSCOMMAND, _
'        &HF012&, 0&
End Sub

0
DeAnCommented:
you should use a PictureBox instead of Image for that code to work.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LosBearAuthor Commented:
so image wont' work?
0
LosBearAuthor Commented:
Well done; it worked like a charm.  I set the picture box properties to flat, no border, etc. and it works!
Thanks dude
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.