Hi Experts;
I am creating a project and I want user can move my form inside of the screen only. How can I do this ? Please help.

It can be done, but it isn't pretty. First, you have to intercept the mouse event message WM_NCLBUTTONUP from the non-client area (e.g. the title bar) then check the position of the window being dragged and re-set the top and left properties. You have to create your own message loop to intercept the message because the default event procedures given by VB for a form don't include non-client area events.

If you don't know what I'm talking about, or don't know how to intercept messages, then you have quite a bit of reading to do. Here's a link to a VERY short introduction of how to do this: http://www.garybeene.com/code/visual%20basic30.htm Read it, and if it still doesn't make sense then you should think again about whether you want to implement the functionality.

Good luck!

Apparently there is a problem trying to use the WM_NCLBUTTONUP message... there is a workaround if you decide to do this. Look at this URL, near the bottom under "Community Content": http://msdn.microsoft.com/en-us/library/ms645621(v=vs.85).aspx

Again, good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.