How to prevent a form from moving

Hi, I would like that my form inherit from Form (which has this.ControlBox = false; this.FormBorderStyle = FormBorderStyle.FixedToolWindow; ) would not allow moving. I have try to override OnMove, but I do not achieve my aim, I guess it just do not call the associate delegate. Any help is welcome, thank you

2 Replies

AD Administrator Syncfusion Team September 10, 2003 07:49 PM UTC

Hi Steve, This is not exactly a solution, but you can try setting the FormBorderStyle to "None". This prevents the user from moving the form. Regards, Br. > > Hi, > > I would like that my form inherit from Form (which has > this.ControlBox = false; > this.FormBorderStyle = FormBorderStyle.FixedToolWindow; > ) would not allow moving. > I have try to override OnMove, but I do not achieve my aim, I guess it just do not call the associate delegate. > > Any help is welcome, > > thank you >


ST Steve September 11, 2003 10:16 AM UTC

I have found a better solution : http://groups.google.de/groups?selm=u1eMJOibDHA.2632%40TK2MSFTNGP09.phx.gbl in VB and I implemented it like this in c#: protected override void WndProc(ref Message m) { const int WM_NCLBUTTONDOWN = 161; const int WM_SYSCOMMAND = 274; const int HTCAPTION = 2; const int SC_MOVE = 61456; if((m.Msg == WM_SYSCOMMAND) && (m.WParam.ToInt32() == SC_MOVE)) { return; } if((m.Msg == WM_NCLBUTTONDOWN) && (m.WParam.ToInt32() == HTCAPTION)) { return; } base.WndProc (ref m); } > Hi Steve, > This is not exactly a solution, but you can try setting the FormBorderStyle to "None". This prevents the user from moving the form. > > Regards, > > Br. > > > > Hi, > > > > I would like that my form inherit from Form (which has > > this.ControlBox = false; > > this.FormBorderStyle = FormBorderStyle.FixedToolWindow; > > ) would not allow moving. > > I have try to override OnMove, but I do not achieve my aim, I guess it just do not call the associate delegate. > > > > Any help is welcome, > > > > thank you > > >

Loader.
Up arrow icon