I use following code to drag borderless form by clicking and dragging the form itself. It works, but it doesn't for when you click and drag a control located on the form. I need to be able to drag it when clicked on some of the controls but not others - drag by labels, but don't by buttons and text boxes. How do I do it?
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
const int WM_NCHITTEST = 0x84;
const int HTCLIENT = 0x1;
const int HTCAPTION = 0x2;
if (m.Msg == WM_NCHITTEST && (int)m.Result == HTCLIENT)
m.Result = (IntPtr)HTCAPTION;
}