开发者

How to move WinForm window without border but with a panel covering the whole area

I saw the code posted on this forum for moving the WinForm without borders but my dialog (C#) has a panel covering the whole area. I know I have to use WndProc to do this. I don't know what to do at this point. My window doesn't move unless I expose some of it by shrinking the size of the panel. Thank you.

The code I have:

protected override void WndPro(re开发者_StackOverflow社区f Message m)
{
  switch(m.Msg)
  {
   case 0x84:m.Result = new intPtr(0x2);
   return 
   }
base.wndProc(ref m);
}


You'll need to give the panel the same kind of treatment, except that you return HTTRANSPARENT. That makes it transparent to hit tests and the form will get the message. Now it works. Add a class to your project and paste the code shown below. Compile. Replace your existing panel with this one.

using System;
using System.Windows.Forms;

class BackPanel : Panel {
    protected override void WndProc(ref Message m) {
        if (m.Msg == 0x84) m.Result = (IntPtr)(-1);
        else base.WndProc(ref m);
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜