This is initialized with windows messages for a paint event, kill and set focus. RunPendingMessages fires the killFocus and setfocus from inside the paint.
Inheritance: TestControl1
Esempio n. 1
0
        public void KillFocusAndGetFocusInPaint()
        {
            // need to create a dummy form because PaintEventArgs wants a Graphics object
            using (DummyForm dummy = new DummyForm())
            {
                dummy.Create();
                // Similate OnPaint, inside which we get a kill focus and a SetFocus.
                using (System.Drawing.Graphics g = dummy.CreateGraphics())
                {
                    PaintEventArgs pe1          = new PaintEventArgs(g, new System.Drawing.Rectangle(0, 1, 2, 3));
                    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));
                    TestControl3   tc3          = new TestControl3(pe1, msgKillFocus, msgSetFocus);

                    tc3.CallOnPaint(pe1);

                    object[] expected = { pe1, pe1, msgKillFocus, msgKillFocus, msgSetFocus, msgSetFocus };
                    VerifyArray(expected, tc3);
                }
            }
        }
Esempio n. 2
0
		public void KillFocusAndGetFocusInPaint()
		{
			// need to create a dummy form because PaintEventArgs wants a Graphics object
			using (DummyForm dummy = new DummyForm())
			{
				dummy.Create();
				// Similate OnPaint, inside which we get a kill focus and a SetFocus.
				using (var g = dummy.CreateGraphics())
				{
					using (var pe1 = new PaintEventArgs(g, new System.Drawing.Rectangle(0, 1, 2, 3)))
					{
						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));
						using (var tc3 = new TestControl3(pe1, msgKillFocus, msgSetFocus))
						{
							tc3.CallOnPaint(pe1);

							object[] expected = { pe1, pe1, msgKillFocus, msgKillFocus, msgSetFocus, msgSetFocus };
							VerifyArray(expected, tc3);
						}
					}
				}
			}
		}