Microsoft KB Archive/230057

= How To Implement Filled Geometric Lines In Windows 95 & 98 =

Article ID: 230057

Article Last Modified on 2/12/2007

-

APPLIES TO


 * Microsoft Windows 98 Standard Edition, when used with:
 * Microsoft Win32 Application Programming Interface

-



This article was previously published under Q230057



SUMMARY
In Windows 95 and 98 using ExtCreatePen, you cannot create a (wide) geometric pen that is filled by a brush pattern. As a result, Windows 95 and 98 geometric pens (the PS_GEOMETRIC style) are limited to the BS_SOLID brush style specified in the LOGBRUSH structure passed to ExtCreatePen.



MORE INFORMATION
However, to achieve a similar effect you can use paths such as the following code demonstrates.

/* Demonstrates patterned pen effect using paths. */ /* This is a Demo only...no error handling. */ void DemoPatternPen(HDC hDC, HBITMAP hBitmap, int iWidth, int x1, int y1, int x2, int y2) {   HBRUSH hBrush, hOldBrush; LOGBRUSH lb; HPEN hPen, hOldPen; BOOL bFlag;

/* Create and select a brush... */    hBrush = CreatePatternBrush(hBitmap); hOldBrush = SelectObject(hDC, hBrush);

/* Create and select a wide geometric pen... */    ZeroMemory(&lb, sizeof(LOGBRUSH)); lb.lbStyle = BS_SOLID; lb.lbColor = RGB(0,0,0); hPen = ExtCreatePen(PS_GEOMETRIC, iWidth, &lb, 0, NULL); hOldPen = SelectObject(hDC, hPen);

/* Create a path containing the line(s) we want to fill... */    bFlag = BeginPath(hDC); MoveToEx(hDC, x1, y1, NULL); LineTo(hDC, x2, y2); bFlag = EndPath(hDC);

/* Fill (widened, pen-width) path with our brush... */    bFlag = WidenPath(hDC); bFlag = FillPath(hDC);

/* Cleanup... */    SelectObject(hDC, hOldBrush); DeleteObject(hBrush); SelectObject(hDC, hOldPen); DeleteObject(hPen);

return; }

Additional query words: BS_PATTERN

Keywords: kbdswgdi2003swept kbgdi kbhowto KB230057

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.