Click here to Skip to main content
16,022,400 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Me.Capture = False
Dim msg As Message = Message.Create(Me.Handle, &HA2, New IntPtr(2), IntPtr.Zero)
Me.DefWndProc(msg)




This is the code of moving form in mousemove event,but how its work??
Posted
Comments
Sergey Alexandrovich Kryukov 14-Jun-12 17:58pm    
This is a stupid code which uses general message processing in Windows.Forms; and the behavior depends on parameters. You can find information in Win32 WM_... documentation (on each Windows message separately)...
--SA

1 solution

Either learn Win32 (without any concern to .NET) and then learn how System.Window.Forms.Form works with Windows API. However, writing the code like this makes no sense at all. What to move a form? Use the instance properties of the class System.Window.Forms.Form: Location or Left and Top, that's all. Please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx[^].

You should understand that sending and handling so called Windows messages (especially between different processes) is old and specifically Windows mechanism. Microsoft people having hard time trying to get rid of it, and the biggest steps are creation of WPF, and, from the other hand, creation of novel OS like Singularity and working on new ones, like Midory (code name), Barrelfish, etc.

By using Windows messages directly in your application, you risk platform compatibility of your application. Did you know that, if you write a Form application accurately, despite the fact that System.Window.Forms is not a standard library, you still can run such application on many platforms (like different versions of Windows, Linux, Mac OS X and more, with different instruction-set architectures) without recompilation? (You can do it through Mono, http://en.wikipedia.org/wiki/Mono_%28software%29[^], http://www.mono-project.com/Main_Page[^]). Why spoiling all that? Try to use pure .NET.

—SA
 
Share this answer
 
Comments
Maciej Los 14-Jun-12 18:13pm    
Good answer, especially this part: (...) called Windows messages (especially between different processes) is old and specifically Windows mechanism (...) ;) My 5!
Sergey Alexandrovich Kryukov 14-Jun-12 18:44pm    
Thank you, Maciej.
--SA
Espen Harlinn 14-Jun-12 18:26pm    
5'ed!
Sergey Alexandrovich Kryukov 14-Jun-12 18:44pm    
Thank you, Espen.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900