468,769 Members | 2,289 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,769 developers. It's quick & easy.

Moving a form with mouse-down on a picture control

VBWheaties
145 100+
In vb.net, I want to allow a user to click and drag a form like what is supported when you click and drag a moveable forms title bar: you click and hold titlebar, then move the mouse, the form moves with the mouse. Ide like to be able to do this but with an area on the form.

For example, I have a picturebox on the form. When the mouse is down on the picture and they move the mouse, I would like the form to move with it.

Any idea how this can be done?
Mar 3 '08 #1
3 2409
Hi,

The whole form can be moved by clicking on any location other than the title bar using the code in the below given link.This example considers that there is no border for the form.That case can be ignored.

TechiSolutions Solution

Cheers..
Mar 4 '08 #2
VBWheaties
145 100+
Hi,

The whole form can be moved by clicking on any location other than the title bar using the code in the below given link.This example considers that there is no border for the form.That case can be ignored.

TechiSolutions Solution

Cheers..
Thanks for the link.
I could not get it to work. More specifically, the set to the property of the m.result does not do anything.
I'll keep playing with it until it works.
I'm sure i'll be able to do something with it.
Thanks again

btw, here is the code (*converted from C# to VB):
Expand|Select|Wrap|Line Numbers
  1.     Protected Overrides Sub WndProc(ByRef m As Message)
  2.         ' Let the base class have first crack
  3.         MyBase.WndProc(m)
  4.         Dim WM_NCHITTEST As Integer = 132 ' winuser.h
  5.         ' If the user clicked on the client area,
  6.         ' ask the OS to treat it as a click on the caption
  7.         If m.Msg <> WM_NCHITTEST Then
  8.             Return
  9.         End If
  10.         Dim HTCLIENT As Integer = 1
  11.         Dim HTCAPTION As Integer = 2
  12.         If m.Result.ToInt32() = HTCLIENT Then
  13.             m.Result = CType(HTCAPTION, IntPtr)
  14.         End If
  15.     End Sub
  16.  
Mar 4 '08 #3
Killer42
8,435 Expert 8TB
Did you manage to get this working?
Mar 25 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Borys Power | last post: by
2 posts views Thread by willem | last post: by
reply views Thread by Sam Sungshik Kong | last post: by
2 posts views Thread by Bevo | last post: by
3 posts views Thread by Robert Lochon | last post: by
1 post views Thread by Chris Dunaway | last post: by
10 posts views Thread by cjparis | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.