Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 230057 - Last Review: February 12, 2007 - Revision: 1.5
How To Implement Filled Geometric Lines In Windows 95 & 98
This article was previously published under Q230057
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.
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;
}
APPLIES TO
- Microsoft Windows 98 Standard Edition, when used with:
- Microsoft Win32 Application Programming Interface
| kbdswgdi2003swept kbgdi kbhowto KB230057 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate