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

前端 未结 1 1927
忘掉有多难
忘掉有多难 2021-01-26 03:46

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 d

1条回答
  •  醉话见心
    2021-01-26 04:08

    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 讨论(0)
提交回复
热议问题