get font from HDC
Hi,
I would like to modify a function used to render some HTML and use the
font I have choosen :
// C functions
int __stdcall DrawHTML(
HDC hdc, // handle of device context
LPCTSTR lpString, // address of string to draw
int nCount, // string length, in characters
LPRECT lpRect, // address of structure with
formatting dimensions
UINT uFormat // text-drawing flags
)
{
....
/* get the "default" font from the DC */
SavedDC = SaveDC(hdc);
hfontBase = (HFONT)SelectObject(hdc, (HFONT)GetStockObject(SYSTEM_FONT));
SelectObject(hdc, hfontBase);
/* clear the other fonts, they are created "on demand" */
for (Index = 0; Index < FV_NUMBER; Index++)
hfontSpecial[Index] = NULL;
hfontSpecial[0] = hfontBase;
....
}
Here is my code :
void CxListCtrl::DrawItem(CDC *pDC, CRect rcItem, HTMLLIST_ITEM *pItem,
BOOL bSelected)
{
CFont* pOldFont = MemDC.SelectObject( &m_font );
DrawHTML(pDC->GetSafeHdc(),pItem->sItemText,pItem->sItemText.GetLength(),
&rc,DT_LEFT|DT_WORDBREAK);
}
My problem is I don't know how to modify DrawHTML to take the font
specified in DrawItem because from what I understand DrawHTML is using a
default font :
hfontBase = (HFONT)SelectObject(hdc, (HFONT)GetStockObject(SYSTEM_FONT));
SelectObject(hdc, hfontBase);