static void UsingApplication() { WinForm form = new WinForm(); form.Click += new EventHandler((sender, eventArgs) => { WriteLine("Closing Window..."); Application.Exit(); }); WriteLine("Starting Window Application..."); Application.Run(form); WriteLine("Exiting Window Application..."); }
static void FormAndCotrol() { Button button = new Button(); button.Text = "Click Me"; button.Left = 100; button.Top = 50; button.Click += ((object sender, EventArgs e) => { MessageBox.Show("딸깍!"); }); WinForm form = new WinForm(); form.Text = "Form & Contrl"; form.Controls.Add(button); Application.Run(form); }
static void FormSize() { void form_MouseDown(object sender, MouseEventArgs e) { Form _form = (Form)sender; int oldWidth = _form.Width; int oldHeight = _form.Height; if (e.Button == MouseButtons.Left) { if (oldWidth < oldHeight) { _form.Width = oldHeight; _form.Height = oldWidth; } } else if (e.Button == MouseButtons.Right) { if (oldHeight < oldWidth) { _form.Width = oldHeight; _form.Height = oldWidth; } } WriteLine("윈도우의 크기가 변경되었습니다."); WriteLine($"Width : {_form.Width}, Height : {_form.Height}"); } WinForm form = new WinForm(); form.Width = 300; form.Height = 200; form.MouseDown += new MouseEventHandler(form_MouseDown); Application.Run(form); }
static void SimpleWindows() { WinForm form = new WinForm(); System.Windows.Forms.Application.Run(form); }