Программирование - это просто
Advertisement
arrow arrow Visual C# arrow Visual C# . 10. (EventArgs, WindowState).
07.02.2023 .
1:
C#
Delphi
Web-
Excel-
.
Visual C# . 10. (EventArgs, WindowState). E-mail
megabax   
02.02.2012 .
Delphi

Visual C# . 10. (EventArgs, WindowState).

.

. Windows :) , . , , 1. , . . , 2, Text "Close",   *:

Visual C#  .  10.   (EventArgs, WindowState).

Text " ", , . *:

Visual C#  .  10.   (EventArgs, WindowState).

, "" - . "" - , "Ctrl". Close (). , . *:

private Random r = new Random();

Visual C#  .  10.   (EventArgs, WindowState).

.

, , Close, ( 1):

        private void button1_Click(object sender, EventArgs e)

        {

            Close();

        }

. . "" "", *:

Visual C#  .  10.   (EventArgs, WindowState).

*:

Visual C#  .  10.   (EventArgs, WindowState).

MouseMove , , .   :

        private void button2_MouseMove(object sender, MouseEventArgs e)

        {

            if (Control.ModifierKeys == Keys.Control) return;

            button2.Location = new Point(r.Next(ClientRectangle.Width - 5), r.Next(ClientRectangle.Height - 5));

        }

, Ctrl , , ( Location). , " ", , . Next, ( 0 ).  , , "".

, . "" . , ( ):

        private void button2_Click2(object sender, EventArgs e)

        {

            if (WindowState == FormWindowState.Normal)

            {

                WindowState = FormWindowState.Maximized;

            }

            else

            {

                WindowState = FormWindowState.Normal;

            }

        }

, , "" .  , , Ctrl   " ":

        private void button2_Click(object sender, EventArgs e)

        {

            button2.Text = "";

            button2.MouseMove -= button2_MouseMove;

            button2.Click -= button2_Click;

            button2.Click += button2_Click2;

        }

, "" ? , "". ,   , "" . , ( ) , "", : .  : +=, -=.

.

MouseDown :

        private void Form1_MouseDown(object sender, MouseEventArgs e)

        {

            button1.Location = new Point(e.X - button1.Width/2, e.Y - button1.Height / 2);

            if (button2.Text != "")

            {

                button2.Text = "";

                button2.MouseMove += button2_MouseMove;

                button2.Click += button2_Click;

                button2.Click -= button2_Click2;

            }

        }

, "".  , . , , . , "" "".

, , SizeChanged . , , : , , ( ):

        private void Form1_SizeChanged(object sender, EventArgs e)

        {

            label1.Text = " ";

            if (!ClientRectangle.IntersectsWith(button1.Bounds)) button1.Location=new Point(10, 10);

            if (!ClientRectangle.IntersectsWith(button2.Bounds)) button2.Location=new Point(10, 10);

        }

10,10, .

, :

Visual C#  .  10.   (EventArgs, WindowState).


, *,   "Microsoft Visual Studio 2010 Professional", Microsoft.. 


 

 

()

 

( 12.02.2014 . )
 
« .   . »
 
© 2023 Программирование - это просто
Joomla! - , GNU/GPL.
© 2005-2008 Joom.Ru - Joomla!
Design by Mamboteam.com | Powered by Mambobanner.de
  .