Make a borderless form movable?

前端 未结 21 2020
情歌与酒
情歌与酒 2020-11-22 09:48

Is there a way to make a form that has no border (FormBorderStyle is set to \"none\") movable when the mouse is clicked down on the form just as if there was a border?

21条回答
  •  孤城傲影
    2020-11-22 10:29

    Ref. video Link

    This is tested and easy to understand.

    protected override void WndProc(ref Message m)
    {
        switch (m.Msg)
        {
            case 0x84:
                base.WndProc(ref m);
                if((int)m.Result == 0x1)
                    m.Result = (IntPtr)0x2;
                return;
        }
    
        base.WndProc(ref m);
    }
    

提交回复
热议问题