CSHARPWINDOWSFORM Telegram 131
بسم الله الرحمن الرحيم

اليوم سوف نشرح طريقة أخرى لكيفية تحريك الفورم في حال كانت خاصية FormBorderStyle=none

الطريقة الاولى التي شرحناها في موضوع Custom Control Box الأداة التي كانت تقوم بتحريك الفورم هي panel وكنا نقوم بكتابة الاكواد المطلوبة في كل دالة حدث
MouseDown,MouseUp,MouseMove

الان شاهد الكود التالي والذي قمنا بكتابته داخل دالة البناء للفورم
int x, y;
public Form1()
{
InitializeComponent();


this.Load += delegate (object Sender, EventArgs E)
{

Button1.MouseDown += delegate (object Send, MouseEventArgs M)
{
this.AllowDrop = true;

y = Cursor.Position.Y - this.DesktopLocation.Y;
x = Cursor.Position.X - this.DesktopLocation.X;
};
};
Button1.MouseUp += delegate (object Send, MouseEventArgs E)
{
AllowDrop = false;
};

Button1.MouseMove += delegate (object Sender, MouseEventArgs E)
{
if (AllowDrop)
{
this.DesktopLocation = new Point(Cursor.Position.X - x, Cursor.Position.Y - y);
}

};
}
الان عندما تضغط على الزر button1 وتقوم بتحريك سوف يتم سحب الفورم من مكان الى اخر


شاهد هذا الكود ايضاً

int x, y;
public Form1()
{
InitializeComponent();


this.Load += delegate (object Sender, EventArgs E)
{

this.MouseDown += delegate (object Send, MouseEventArgs M)
{
this.AllowDrop = true;

y = Cursor.Position.Y - this.DesktopLocation.Y;
x = Cursor.Position.X - this.DesktopLocation.X;
};
};
this.MouseUp += delegate (object Send, MouseEventArgs E)
{
AllowDrop = false;
};

this.MouseMove += delegate (object Sender, MouseEventArgs E)
{
if (AllowDrop)
{
this.DesktopLocation = new Point(Cursor.Position.X - x, Cursor.Position.Y - y);
}

};
}

الان الفورم هو الذي سوف يقوم بتحريك نفسه
عندما تحدث الاحداث التالية MouseDown و MouseMove
الكودين السابقين يعملين سوا كانت الخاصية FormBordeStyle
تساوي أي قيمة

انتهى ...........



tgoop.com/CsharpWindowsForm/131
Create:
Last Update:

بسم الله الرحمن الرحيم

اليوم سوف نشرح طريقة أخرى لكيفية تحريك الفورم في حال كانت خاصية FormBorderStyle=none

الطريقة الاولى التي شرحناها في موضوع Custom Control Box الأداة التي كانت تقوم بتحريك الفورم هي panel وكنا نقوم بكتابة الاكواد المطلوبة في كل دالة حدث
MouseDown,MouseUp,MouseMove

الان شاهد الكود التالي والذي قمنا بكتابته داخل دالة البناء للفورم
int x, y;
public Form1()
{
InitializeComponent();


this.Load += delegate (object Sender, EventArgs E)
{

Button1.MouseDown += delegate (object Send, MouseEventArgs M)
{
this.AllowDrop = true;

y = Cursor.Position.Y - this.DesktopLocation.Y;
x = Cursor.Position.X - this.DesktopLocation.X;
};
};
Button1.MouseUp += delegate (object Send, MouseEventArgs E)
{
AllowDrop = false;
};

Button1.MouseMove += delegate (object Sender, MouseEventArgs E)
{
if (AllowDrop)
{
this.DesktopLocation = new Point(Cursor.Position.X - x, Cursor.Position.Y - y);
}

};
}
الان عندما تضغط على الزر button1 وتقوم بتحريك سوف يتم سحب الفورم من مكان الى اخر


شاهد هذا الكود ايضاً

int x, y;
public Form1()
{
InitializeComponent();


this.Load += delegate (object Sender, EventArgs E)
{

this.MouseDown += delegate (object Send, MouseEventArgs M)
{
this.AllowDrop = true;

y = Cursor.Position.Y - this.DesktopLocation.Y;
x = Cursor.Position.X - this.DesktopLocation.X;
};
};
this.MouseUp += delegate (object Send, MouseEventArgs E)
{
AllowDrop = false;
};

this.MouseMove += delegate (object Sender, MouseEventArgs E)
{
if (AllowDrop)
{
this.DesktopLocation = new Point(Cursor.Position.X - x, Cursor.Position.Y - y);
}

};
}

الان الفورم هو الذي سوف يقوم بتحريك نفسه
عندما تحدث الاحداث التالية MouseDown و MouseMove
الكودين السابقين يعملين سوا كانت الخاصية FormBordeStyle
تساوي أي قيمة

انتهى ...........

BY برمجة تطبيقات الويندوز C# Programming


Share with your friend now:
tgoop.com/CsharpWindowsForm/131

View MORE
Open in Telegram


Telegram News

Date: |

Telegram iOS app: In the “Chats” tab, click the new message icon in the right upper corner. Select “New Channel.” Ng was convicted in April for conspiracy to incite a riot, public nuisance, arson, criminal damage, manufacturing of explosives, administering poison and wounding with intent to do grievous bodily harm between October 2019 and June 2020. The creator of the channel becomes its administrator by default. If you need help managing your channel, you can add more administrators from your subscriber base. You can provide each admin with limited or full rights to manage the channel. For example, you can allow an administrator to publish and edit content while withholding the right to add new subscribers. Each account can create up to 10 public channels fire bomb molotov November 18 Dylan Hollingsworth yau ma tei
from us


Telegram برمجة تطبيقات الويندوز C# Programming
FROM American