Brush objects
The Brush object pen is used to draw contour lines of shapes on the device environment DC, such as rectangles, circles, and polygons, and the contour of the shape has three properties of line type, thickness, and color, which we all need to represent in a Pen object. In GDI's API functions, when manipulating brushes, we have the following commonly used functions:
1 Public Declare FunctionCreatePenLib "GDI32" Alias "CreatePen"(ByValNpenstyle as Long,ByValNwidth as Long,ByValCrcolor as Long) as Long2 Public Declare FunctionCreatepenindirectLib "GDI32" Alias "Createpenindirect"(Lplogpen asLogpen) as Long3 Public Declare FunctionExtcreatepenLib "GDI32" Alias "Extcreatepen"(ByValDwpenstyle as Long,ByValDwwidth as Long, LPLB asLogbrush,ByValDwstylecount as Long, Lpstyle as Long) as Long4 Public Declare FunctionSelectObjectLib "GDI32" Alias "SelectObject"(ByValhDC as Long,ByValHobject as Long) as Long
function |
function |
CreatePen |
Creates a brush object based on the provided line type, width, and color |
Createpenindirect |
Create a brush based on a logical font structure |
Extcreatepen |
Create an extension brush |
SelectObject |
Selecting brushes in the device environment |
Once we have created a brush by creating a type of Create brush function, we have to select it into the device environment DC and use the function SelectObject, which is the outline of the drawing on the device environment that is displayed based on the brush. When the brush is finished, we need to call the SelectObject again, restore the brush in the device environment DC, and finally we need to remove it using DeleteObject.
GDI programming in VB-2 brushes