Hello Elby,
The following code can let you move control smoothly in run time. Please take a look.
public partial class Form1 : Form
{
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2;
[DllImport("User32.dll")]
public static extern bool ReleaseCapture();
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
public Form1()
{
InitializeComponent();
this.panel1.MouseDown += new MouseEventHandler(panel1_MouseDown);
}
void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(this.panel1.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}
}
The example shows how to call win32 api “SendMessage�and “ReleaseCapture�to move the panel1 control. If you have anything unclear, please feel free to tell me.
Sincerely,
Kira Qian
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the
All-In-One Code Framework!