Hi. I want to have a borderless window which handles mouse clicks in the
normal way. BUT, when the user DRAGs the window (as opposed to clicking it),
I want to start moving the window with the user's drag. How do I determine
when the user is DRAGGING within the window and then how do I handle window
movement based on the user's dragging?
Alex
Tim Wilson - 16 Feb 2006 18:02 GMT
See the thread linked below.
http://groups.google.com/group/microsoft.public.dotnet.framework.windowsforms/br
owse_thread/thread/377f818a1b682354/2d514547ff462897?hl=en#2d514547ff462897

Signature
Tim Wilson
.NET Compact Framework MVP
> Hi. I want to have a borderless window which handles mouse clicks in the
> normal way. BUT, when the user DRAGs the window (as opposed to clicking it),
[quoted text clipped - 3 lines]
>
> Alex
Herfried K. Wagner [MVP] - 16 Feb 2006 23:31 GMT
"Alex Maghen" <AlexMaghen@newsgroup.nospam> schrieb:
> Hi. I want to have a borderless window which handles mouse clicks in the
> normal way. BUT, when the user DRAGs the window (as opposed to clicking
[quoted text clipped - 3 lines]
> window
> movement based on the user's dragging?
<URL:http://dotnetrix.co.uk/misc.html>
-> "Move a borderless form."
-> "An example of a moveable/resizable shaped form."

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
"TerryFei" - 23 Feb 2006 07:37 GMT
Hi Alex,
Welcome to MSDN Newsgroup!
If we want to do dragaing window with borderless style, we could handle the
WM_NVHITTEST message and return HTCAPTION for this purpose.
The WM_NCHITTEST message will be sent when the mouse is moved through it or
a mouse click is made on it. The function returns one of several enumerated
values, each of which indicates where the mouse action took place. Now one
of these enumerated values is HTCAPTION which indicates that the mouse
action took place on the title bar. So what we do is to verify if the mouse
is currently within the client area of the window, and if it is within the
client area of the window, we check if the mouse is down through a flag
that is set and unset from the LButtonDown and LButtonUp handlers. If all
our checks are passed, we return HTCAPTION, thus fooling the OS into
thinking that the action is taking place on the title bar. It is very
important to verify that the mouse action is within the window'slient area,
otherwise any buttons we have on the title bar, like the close and maximize
buttons will be rendered useless.
I hope the above information is helpful for you. Thanks and have a nice day!
Best Regards,
Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security