public void NormalOperation() { // need to create a dummy form because PaintEventArgs wants a Graphics object using (DummyForm dummy = new DummyForm()) { dummy.Create(); using (TestControl1 tc1 = new TestControl1()) { Message m1 = Message.Create(IntPtr.Zero, 10, new IntPtr(101), new IntPtr(1001)); tc1.CallWndProc(ref m1); Message m2 = Message.Create(IntPtr.Zero, 20, new IntPtr(201), new IntPtr(2001)); tc1.CallWndProc(ref m2); using (var g = dummy.CreateGraphics()) { using (var pe1 = new PaintEventArgs(g, new System.Drawing.Rectangle(0, 1, 2, 3))) { tc1.CallOnPaint(pe1); Message m3 = Message.Create(IntPtr.Zero, 30, new IntPtr(301), new IntPtr(3001)); tc1.CallWndProc(ref m3); object[] expected = { m1, m1, m2, m2, pe1, pe1, m3, m3 }; VerifyArray(expected, tc1); } } } } }
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); } } } } }