Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2006

Tip: Looking for answers? Try searching our database.

Borderless Window Drag/Move Handling in C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex Maghen - 16 Feb 2006 17:39 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.