c# - Move a borderless Winform holding right mouse button, possibly with native methods -


i have situation move windows form holding right mouse button on it's client area; form it's borderless i've stated.

i move "natively" (if possible, otherwise other answers ok too). mean way behaves when hold left mouse button on titlebar (with mouse-move , things lot of strange behaviours, maybe it's me).

i've read around lot of things , post looks helpful

http://social.msdn.microsoft.com/forums/en-us/csharpgeneral/thread/b9985b19-cab5-4fba-9dc5-f323d0d37e2f/

i tried various way use , watched through http://msdn.microsoft.com/en-us/library/ff468877%28v=vs.85%29.aspx find other useful things , wm_ncrbuttondown came in mind, wndproc doesn't detect it, maybe because it's handled form?

any suggestion appreciated, thanks

francesco

public partial class dragform : form {     // offset upper left of form mouse grabbed     private size? _mousegraboffset;      public dragform()     {         initializecomponent();     }      protected override void onmousedown(mouseeventargs e)     {         if( e.button == system.windows.forms.mousebuttons.right )             _mousegraboffset = new size(e.location);          base.onmousedown(e);     }      protected override void onmouseup(mouseeventargs e)     {         _mousegraboffset = null;          base.onmouseup(e);     }      protected override void onmousemove(mouseeventargs e)     {         if (_mousegraboffset.hasvalue)         {             this.location = cursor.position - _mousegraboffset.value;         }          base.onmousemove(e);     } } 

Comments