Share via


CBrush::GetLogBrush

int GetLogBrush( LOGBRUSH* pLogBrush );

Return Value

If the function succeeds, and pLogBrush is a valid pointer, the return value is the number of bytes stored into the buffer.

If the function succeeds, and pLogBrush is NULL, the return value is the number of bytes required to hold the information the function would store into the buffer.

If the function fails, the return value is 0.

Parameters

pLogBrush

Points to a structure that contains information about the brush.

Remarks

Call this member function to retrieve the LOGBRUSH structure. The LOGBRUSH structure defines the style, color, and pattern of a brush.

For example, call GetLogBrush to match the particular color or pattern of a bitmap.

Example

// Example for CBrush::GetLogBrush
LOGBRUSH logbrush;
brushExisting.GetLogBrush( &logbrush );
CBrush brushOther( logbrush.lbColor);

// Another example
// Declare a LOGBRUSH
LOGBRUSH logBrush;

// Using a bitmap for this example.
// The bitmap should be a project resource.
CBitmap bm;
bm.LoadBitmap(IDB_BRUSH);

try
{
   // Create a brush
   CBrush brush1(&bm);

   // Use GetLogBrush to fill the LOGBRUSH structure
   brush1.GetLogBrush(&logBrush);

   // Create a second brush using the LOGBRUSH data
   CBrush brush2;
   brush2.CreateBrushIndirect(&logBrush);

   // Use the first brush
   CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush1);
   pDC->Rectangle(CRect(50,50,150,150));

   // The second brush has the specified characteristics
   // of the first brush
   CBrush* pTempBrush = (CBrush*)pDC->SelectObject(&brush2);
   pDC->Ellipse(200,50,300,150);

   // Reselect the original brush
   pDC->SelectObject(pOldBrush);
}
catch(CResourceException* e)
{
   e->ReportError();
   e->Delete();
}

CBrush OverviewClass MembersHierarchy Chart

See Also   ,