Click here to Skip to main content
12,954,522 members (56,280 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


5 bookmarked
Posted 13 Jul 2010

Dragging a Borderless Form

, 13 Jul 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
A slightly different solution.using System.Runtime.InteropServices;private const int WM_NCLBUTTONDOWN = 0xA1;private const int HTCAPTION = 0x2;[DllImport("User32.dll")]private static extern bool ReleaseCapture();[DllImport("User32.dll")]private static extern int...
A slightly different solution.

using System.Runtime.InteropServices;

private const int WM_NCLBUTTONDOWN = 0xA1;
private const int HTCAPTION = 0x2;
private static extern bool ReleaseCapture();
private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
public Form()
private void AssignHandler(Control control)
    if (control is Form
        || control is Label
        || control is Panel
        || control is PictureBox
        || control is TableLayoutPanel)
        control.MouseDown += Form_MouseDown;
    foreach (Control subControl in control.Controls)
private void Form_MouseDown(object sender, MouseEventArgs e)
    if (e.Button == MouseButtons.Left)
        SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Dima Popov
Software Developer Energoservice
Russian Federation Russian Federation
Dmitry lives in Arkhangelsk, Russia. He has developed C# applications since 2007.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170525.1 | Last Updated 13 Jul 2010
Article Copyright 2010 by Dima Popov
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid