The CreatePen function is part of the Win32 GDI (Graphics Device Interface) library, which is a package library for Windows. It is used to create a pen object that can be used for drawing lines, curves, and other shapes in a Windows application using C++.
The syntax for creating a pen using CreatePen is as follows:
HPEN hPen = CreatePen(int fnPenStyle, int nWidth, COLORREF crColor);
Where:
- `fnPenStyle` is the style of the pen, such as solid, dashed, dotted, etc. - `nWidth` is the width of the pen in pixels. - `crColor` is the color of the pen.
Here are some examples of using CreatePen in C++:
Example 1: Creating a solid black pen with a width of 1 pixel.
HPEN hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
Example 2: Creating a dashed blue pen with a width of 2 pixels.
Example 3: Creating a dotted green pen with a width of 3 pixels.
HPEN hPen = CreatePen(PS_DOT, 3, RGB(0, 255, 0));
As mentioned earlier, CreatePen is part of the Win32 GDI library, which is a package library for Windows. Therefore, in order to use this function, you need to include the following header file in your C++ application:
#include
C++ (Cpp) CPen::CreatePen - 30 examples found. These are the top rated real world C++ (Cpp) examples of CPen::CreatePen extracted from open source projects. You can rate examples to help us improve the quality of examples.