چگونه فرمی که FormBorderStyle ان None است را حرکت دهیم .
سلام .
من فرم ویندوز اپم رو None کردم یعنی کنترل باکس و از این چیزا نداره .
FormBorderStyle = None
ولی الان دیگه حرکت نمی کنه . وقتی اجرا می شه فقط یک جا ثابت می ماند . چطور کاری کنم با کلیک برو روی فرم و نگاه داشتن ان کلیک و حرکت موس نرم افزارم هم حرکت کنه ؟
نقل قول: چگونه فرمی که FormBorderStyle ان None است را حرکت دهیم .
برای این کار برای فرمتون این 3 تا event رو تعریف کنید:
private void MouseDownEvent(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
{
return;
}
downPoint = new Point(e.X, e.Y);
}
private void MouseMoveEvent(object sender, MouseEventArgs e)
{
if (downPoint == Point.Empty)
{
return;
}
Point location = new Point(
this.Left + e.X - downPoint.X,
this.Top + e.Y - downPoint.Y);
this.Location = location;
}
private void MouseUpEvent(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
{
return;
}
downPoint = Point.Empty;
}
نقل قول: چگونه فرمی که FormBorderStyle ان None است را حرکت دهیم .
سلام
با توابع API هم می تونید این کار رو انجام بدید:
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(this.Handle, 0xa1, 0x2, 0);
}
}
نقل قول: چگونه فرمی که FormBorderStyle ان None است را حرکت دهیم .
نقل قول:
نوشته شده توسط
shahin bahari
برای این کار برای فرمتون این 3 تا event رو تعریف کنید:
private void MouseDownEvent(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
{
return;
}
downPoint = new Point(e.X, e.Y);
}
private void MouseMoveEvent(object sender, MouseEventArgs e)
{
if (downPoint == Point.Empty)
{
return;
}
Point location = new Point(
this.Left + e.X - downPoint.X,
this.Top + e.Y - downPoint.Y);
this.Location = location;
}
private void MouseUpEvent(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Left)
{
return;
}
downPoint = Point.Empty;
}
داداش منظورت از downPoint چیه ؟ ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟