**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Windows.Forms / WINELib / FormTest.cs
blobcf9a4dbd58fe494a2fefff4414d83ccbb1c5f2cf
1 using System;
2 using System.Windows.Forms;
4 // Test basic functionality of the Application and Form class
5 class FormTest : Form {
7 Label label;
8 Button button;
10 public FormTest () : base ()
12 label = new Label ();
13 label.Top = 50;
14 label.Left = 10;
15 label.Width = 50;
16 label.Height = 50;
17 label.Parent = this;
18 label.Text = "Label";
20 button = new Button ();
21 button.Top = 50;
22 button.Left = 120;
23 button.Width = 50;
24 button.Height = 50;
25 button.Parent = this;
26 button.Text = "Button";
29 // - verifies the WndProc can be overridden propery
30 // - verifies the Application.MessageLoop is working properly
31 protected override void WndProc (ref Message m)
33 base.WndProc (ref m);
35 // should be true after the Run command is reached
36 Console.WriteLine ("Application.MessageLoop: " +
37 Application.MessageLoop);
40 public class MouseMoveMessageFilter : IMessageFilter {
42 public bool PreFilterMessage(ref Message m)
44 Console.WriteLine ("PreFilter(ing) message");
46 if (m.Msg == Win32.WM_MOUSEMOVE) {
47 Console.WriteLine ("captured mousemove");
48 return true;
50 return false;
55 static public void Test1 ()
57 MessageBox.Show ("test derived form");
58 FormTest form = new FormTest ();
59 MouseMoveMessageFilter f = new MouseMoveMessageFilter();
60 Application.AddMessageFilter (f);
62 // should be false
63 Console.WriteLine ("Application.MessageLoop: " +
64 Application.MessageLoop);
66 Application.Run (form);
67 Application.RemoveMessageFilter (f);
70 static public void Test2 ()
72 MessageBox.Show ("test non-derived form, ctrl-c from console to quit");
73 Form form = new Form ();
74 form.Show ();
75 Application.DoEvents ();
76 Application.Run ();
79 static public int Main (String[] args)
81 Test1();
82 //Test2();
83 return 0;