Illustration of GDI object CPen:
1. Generate a SDI application. And name it as gdipen.
2. Press ctrl (control key) and W altogether to invoke the class wizard.
3. Choose the message maps tab into the class wizard.
4. Choose the CGdipenView object id and click the WM_MOUSEMOVE message and then click ok.
5. In response OnMouseMove handler will be inserted in the implementation file gdipenView.cpp as shown below.
6. Now type the coding which is below in the handler.
void CGdipenView::OnMouseMove(UINT nFlags, CPoint point)
CPen p(PS_SOLID, 2,
7. The PS_SOLID macro in the CPen constructor tells the pen style. The second parameter is the thickness of the pen, namely 2. The third argument indicates the color of the pen. The other pen object is created as pe. Then the 2 Rectangles with the pens p and pe are drawn.
8. Change the thickness, style, and color.
9. Construct the project and execute it to see the impact of the change incorporated.
10. The rectangles would be exhibited when the mouse is moved in the window exhibited.
11. Change the thickness, color, and style of the pen and examine the output after building and executing the project.