示例#1
0
		public void MethodPreProcessMessage ()
		{
			bool testing_callstack = false;

			MyControl c = new MyControl ();
			Message m = new Message ();
			m.HWnd = c.Handle;
			m.Msg = WM_KEYDOWN;
			m.WParam = (IntPtr)Keys.Down;
			m.LParam = IntPtr.Zero;

			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A1");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.OnPreviewKeyDown);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A2");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessCmdKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (true, c.PreProcessMessage (ref m), "A3");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.IsInputKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A4");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessDialogKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (true, c.PreProcessMessage (ref m), "A5");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());


			m.Msg = WM_CHAR;
			c.SetState (State.None);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A6");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.IsInputChar);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A7");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessDialogChar);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (true, c.PreProcessMessage (ref m), "A8");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());


			m.Msg = WM_SYSCHAR;
			c.SetState (State.None);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A9");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.IsInputChar);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A10");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessDialogChar);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (true, c.PreProcessMessage (ref m), "A11");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());


			m.Msg = WM_KEYUP;
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A12");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.OnPreviewKeyDown);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A13");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessCmdKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A14");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.IsInputKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A15");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());

			c.SetState (State.ProcessDialogKey);
			if (testing_callstack) Console.WriteLine ("Start");
			Assert.AreEqual (false, c.PreProcessMessage (ref m), "A16");
			if (testing_callstack) Console.WriteLine ("End {0}\n", m.WParam.ToString ());
		}