forked from MicrosoftDocs/cpp-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcbrush-class_7.cpp
More file actions
43 lines (35 loc) · 983 Bytes
/
cbrush-class_7.cpp
File metadata and controls
43 lines (35 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// 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
pDC->SelectObject(&brush2);
pDC->Ellipse(200, 50, 300, 150);
// Reselect the original brush
pDC->SelectObject(pOldBrush);
}
catch (CResourceException *e)
{
e->ReportError();
e->Delete();
}