OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Accessing TBrush

You can access TBrush through an HBRUSH or as a LOGBRUSH structure.

To get an HBRUSH from a TBrush object, use the HBRUSH() operator with the TBrush object as the parameter. The HBRUSH() operator, listed below, is almost never explicitly invoked:

{
return brush;
}

This code automatically invokes the HBRUSH() conversion operator to cast the TBrush object to the correct type.

To convert a TBrush object to a LOGBRUSH structure, use the TBrush::GetObject function:

{
TBrush brush(TColor::LtCyan, HS_DIAGCROSS);
return brush.GetObject(logBrush);
}

To reset the origin of a brush object, use the TBrush::UnrealizeObject function, which resets the brush's origin and returns a nonzero value if successful.

The following code shows how to use a brush to paint a rectangle in a window:

void
TMyWindow::PaintRect(TDC& dc, TPoint& p, TSize& size)
{
TBrush brush(TColor(5,5,5));
dc.SelectObject(brush);
dc.Rectangle(p, size);
dc.RestoreBrush();
}

See Also