How can I move a borderless form with a panel
I have a panel and I want to move the main form by the panel.
How can I do this
Thanks,
How can I move a borderless form with a panel
I have a panel and I want to move the main form by the panel.
How can I do this
Thanks,
How can I move a borderless form with a panel?
gumtoo
private Point mMousePos;
private Point mFormPos;
private bool mDragging;
private void panel1_MouseDown(object sender, MouseEventArgs e) {
mDragging = true;
mMousePos = panel1.PointToScreen(e.Location);
mFormPos = Location;
}
private void panel1_MouseUp(object sender, MouseEventArgs e) {
mDragging = false;
}
private void panel1_MouseMove(object sender, MouseEventArgs e) {
if (!mDragging) return;
Point pos = panel1.PointToScreen(e.Location);
Left = mFormPos.X + pos.X - mMousePos.X;
Top = mFormPos.Y + pos.Y - mMousePos.Y;
}
mahima
you can write some thing like that after adding
using
System.Runtime.InteropServices;private const int WM_NCLBUTTONDOWN = 0xA1;
private 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);
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}