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); } } }
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); } } } } }