This is initialized with windows messages for an activate, a killFocus, and a set focus. RunPendingMessages fires the killFocus and set focus from inside the activate; the activate from inside the keyDown
Inheritance: TestControl1
Beispiel #1
0
        public void KillFocusAndGetFocusInActivateInKeyDown()
        {
            // Similate a Keydown, inside which we get an MdiActivate, inside which we get a kill focus and a GetFocus.
            // Since activate is not being sequenced, but the other two are, we expect the sequence
            // start of keydown, start of activate, end of activate, end of keydown, start of killfocus, end of killfocus, start of get focus, end of get focus.
            Message      msgKeyDown   = Message.Create(IntPtr.Zero, (int)Win32.WinMsgs.WM_KEYDOWN, new IntPtr(101), new IntPtr(1001));
            Message      msgActivate  = Message.Create(IntPtr.Zero, (int)Win32.WinMsgs.WM_MDIACTIVATE, new IntPtr(201), new IntPtr(2001));
            Message      msgKillFocus = Message.Create(IntPtr.Zero, (int)Win32.WinMsgs.WM_KILLFOCUS, new IntPtr(201), new IntPtr(2001));
            Message      msgSetFocus  = Message.Create(IntPtr.Zero, (int)Win32.WinMsgs.WM_SETFOCUS, new IntPtr(301), new IntPtr(3001));
            TestControl2 tc2          = new TestControl2(msgKeyDown, msgActivate, msgKillFocus, msgSetFocus);

            tc2.CallWndProc(ref msgKeyDown);

            object[] expected = { msgKeyDown, msgActivate, msgActivate, msgKeyDown, msgKillFocus, msgKillFocus, msgSetFocus, msgSetFocus };
            VerifyArray(expected, tc2);
        }
		public void KillFocusAndGetFocusInActivateInKeyDown()
		{
			// Similate a Keydown, inside which we get an MdiActivate, inside which we get a kill focus and a GetFocus.
			// Since activate is not being sequenced, but the other two are, we expect the sequence
			// start of keydown, start of activate, end of activate, end of keydown, start of killfocus, end of killfocus, start of get focus, end of get focus.
			Message msgKeyDown = Message.Create(IntPtr.Zero, (int)Win32.WinMsgs.WM_KEYDOWN, new IntPtr(101), new IntPtr(1001));
			Message msgActivate = Message.Create(IntPtr.Zero, (int)Win32.WinMsgs.WM_MDIACTIVATE, new IntPtr(201), new IntPtr(2001));
			Message msgKillFocus = Message.Create(IntPtr.Zero, (int)Win32.WinMsgs.WM_KILLFOCUS, new IntPtr(201), new IntPtr(2001));
			Message msgSetFocus = Message.Create(IntPtr.Zero, (int)Win32.WinMsgs.WM_SETFOCUS, new IntPtr(301), new IntPtr(3001));
			TestControl2 tc2 = new TestControl2(msgKeyDown, msgActivate, msgKillFocus, msgSetFocus);

			tc2.CallWndProc(ref msgKeyDown);

			object[] expected = {msgKeyDown, msgActivate, msgActivate, msgKeyDown, msgKillFocus, msgKillFocus, msgSetFocus, msgSetFocus};
			VerifyArray(expected, tc2);
		}