T
T
TechNOIR2018-03-01 09:26:39
C++ / C#
TechNOIR, 2018-03-01 09:26:39

C#. How to make a form move by removing its border?

Good afternoon. Tell me how to make the form move by removing its frame?
That is, I have MainForm turned off ControlBox and BorderStyle - None
And the form does not move now .. How to return the ability to move it? thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2018-03-01
@petermzg

protected override void WndProc(ref Message m)
{
            switch (m.Msg)
            {
                case WndHelper.WM_NCHITTEST:
                    {
                        m.Result = (IntPtr)WndHelper.HTCAPTION; 
                        return;
                    }
                default:
                    break;
            }
            base.WndProc(ref m);
}

public const int WM_NCHITTEST = 0x84;
public const int HTCAPTION = 0x2;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question