How do I prevent Form Moving

  • Thread starter Thread starter harvie wang
  • Start date Start date
H

harvie wang

Hi,
I create a form.
Can I prevent user to move the window by drag the window title?

best wish,

harvie

2005-10-07
 
I'v get it!
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 );
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top