关闭

C#设置MDI子窗体不可移动

标签: c#returningeventsclassuser
1915人阅读 评论(0) 收藏 举报
分类:
You cannot make the child form stay fixed in the parent form by just chaning a property. You can try catching move events and returning the form in the center every time the user tries to change the position. You can do this by writing the following code in your child form class' code:



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 );

}  
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:90359次
    • 积分:1025
    • 等级:
    • 排名:千里之外
    • 原创:13篇
    • 转载:33篇
    • 译文:0篇
    • 评论:6条
    最新评论