WinForm中禁止窗体移动

设置窗体出现的具体位置:

窗体 form = new 窗体();    
form.StartPosition = FormStartPosition.Manual;
form.Location = new Point(300, 0);
form.Show();    

禁止窗体自由移动:

public const int WM_SYSCOMMAND = 0x112;
public const int SC_MOVE = 0xF012;

protected override void WndProc(ref   Message m)
{
    if (m.Msg == WM_SYSCOMMAND)
    {
        if ((int)m.WParam == SC_MOVE)
            return;
    }
    base.WndProc(ref   m);
}    
posted @ 2012-10-16 17:32  古兰色回忆  阅读(3310)  评论(0编辑  收藏  举报