Hi enhzflep, I incorporated code from your example into my function, and it works with the CreateHatchBrush call to create a new brush. Unfortunately, when I substitute my already-created brush, it doesn't work; I just get solid white filling the text outlines. I've verified the brush handle is the same as the nativeBrush member of my .NET Brush, which draws correctly both before and after. Can you see anything I'm doing wrong?
DLLEXPORT void drawWithGdiFont (HBITMAP hBitmap, HBRUSH hbrush, LPCWSTR fontName,
LPCWSTR text, int sizeToUse, bool bold, bool italic, int br, int bg, int bb)
{
HDC hDc = CreateCompatibleDC (NULL);
HGDIOBJ oldObj = SelectObject (hDc, hBitmap);
SIZE size ;
LOGFONT logFont;
::ZeroMemory(& logFont, sizeof(LOGFONT));
wcscpy ((&logFont)->lfFaceName, fontName);
logFont.lfHeight = sizeToUse;
if (bold)
logFont.lfWeight = 800;
else
logFont.lfWeight = 500;
logFont.lfItalic = italic;
HFONT hFont = CreateFontIndirect(& logFont);
HFONT oldFont = (HFONT) SelectObject (hDc, hFont);
SetBkMode (hDc, TRANSPARENT) ;
BeginPath (hDc) ;
TextOut (hDc, 0, 0, fontName, wcslen (fontName));
EndPath (hDc) ;
**// MY BRUSH FROM .NET (DOESN'T WORK):
HBRUSH oldBrush = (HBRUSH) SelectObject (hDc, hbrush);
// FROM EXAMPLE (WORKS): HBRUSH oldBrush = (HBRUSH) SelectObject (hDc, CreateHatchBrush (HS_DIAGCROSS, RGB (255, 0, 0))) ;**
SetBkColor (hDc, RGB (br, bg, bb));
SetBkMode (hDc, OPAQUE) ;
StrokeAndFillPath (hDc) ;
DeleteObject (SelectObject (hDc, oldFont));
SelectObject (hDc, oldBrush);
DeleteObject (hDc);
}
Also, it seems like the background color here is the second color of the hatch pattern. But how do I set the color between the letters (which is also called the "background color"?) Thanks! Alan
"Microsoft -- Adding unnecessary complexity to your work since 1987!"