Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using hbrush, how to override the default colour

Status
Not open for further replies.

lemming999

Programmer
Mar 11, 2002
12
0
0
IE
Currently I'm trying to create Polygons that are not black which I assume is the default.

This is the code I have but I'm obviously I'm missing something to override the default brush for SetPolyFillMode

BuildingList::drawPolygon(HDC hdc, COLORREF colour)
{
HBRUSH hbrush;

hbrush = CreateSolidBrush(colour);
SetPolyFillMode(hdc, WINDING);
Polygon(hdc, coords,4);

DeleteObject(hbrush);

}
 
BuildingList::drawPolygon(HDC hdc, COLORREF colour)

{
HBRUSH hbrush = CreateSolidBrush(colour);
HBRUSH hOldBrush = SelectObject(hdc,hbrush);

SetPolyFillMode(hdc, WINDING);
Polygon(hdc, coords,4);

SelectObject(hdc,hOldBrush);
DeleteObject(hbrush);
}
 
Hi Jeffray,

I ran the code you gave me, and its giving me this error

initializing' : cannot convert from 'void *' to 'struct HBRUSH__ *'

Conversion from 'void*' to pointer to non-'void' requires an explicit cast

I'm sorry but I dont understand what this error is?

Lemming
 

change the line
HBRUSH hOldBrush = SelectObject(hdc,hbrush);
to
HBRUSH hOldBrush =(HBRUSH) SelectObject(hdc,hbrush);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top