Fonts for CTreeCtrl. What is not right now?
-
I want to set specific font for my tree, so I use CUSTOMDRAW event. I've write two functions that must set my own font, but they do not work:doh: Please, help me. What is incorrect in my functions?
void CMyTree::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTVCUSTOMDRAW pNMTVCD = (LPNMTVCUSTOMDRAW) pNMHDR; HWND hWndTreeView = pNMHDR->hwndFrom; if (pNMHDR->code == NM_CUSTOMDRAW) *pResult = handleCustomDraw(hWndTreeView, pNMTVCD); *pResult = handleCustomDraw(hWndTreeView, pNMTVCD); //*pResult = 0; } long CMyTree::handleCustomDraw(HWND hWndTreeView, LPNMTVCUSTOMDRAW pNMTVCD) { if (pNMTVCD==NULL) { return -1; } switch (pNMTVCD->nmcd.dwDrawStage) { case CDDS_PREPAINT: { return (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW); } case CDDS_ITEMPREPAINT: { LOGFONT lf; lf.lfHeight = 20; lstrcpy(lf.lfFaceName, "Time New Roman"); lf.lfWeight = FW_HEAVY; lf.lfItalic = TRUE; HFONT gh = CreateFontIndirect(&lf);; SelectObject(pNMTVCD->nmcd.hdc, &gh); return (CDRF_NOTIFYPOSTPAINT | CDRF_NEWFONT); } case CDDS_ITEMPOSTPAINT: { LOGFONT lf; lf.lfHeight = 20; lf.lfItalic = TRUE; lstrcpy(lf.lfFaceName, "Time New Roman"); lf.lfWeight = FW_HEAVY; HFONT gh = CreateFontIndirect(&lf);; SelectObject(pNMTVCD->nmcd.hdc, &gh); return CDRF_DODEFAULT; //return (CDRF_NOTIFYPOSTPAINT | CDRF_NEWFONT); } } } return 0; }
Thank to everybody very much in advance.. -
I want to set specific font for my tree, so I use CUSTOMDRAW event. I've write two functions that must set my own font, but they do not work:doh: Please, help me. What is incorrect in my functions?
void CMyTree::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) { LPNMTVCUSTOMDRAW pNMTVCD = (LPNMTVCUSTOMDRAW) pNMHDR; HWND hWndTreeView = pNMHDR->hwndFrom; if (pNMHDR->code == NM_CUSTOMDRAW) *pResult = handleCustomDraw(hWndTreeView, pNMTVCD); *pResult = handleCustomDraw(hWndTreeView, pNMTVCD); //*pResult = 0; } long CMyTree::handleCustomDraw(HWND hWndTreeView, LPNMTVCUSTOMDRAW pNMTVCD) { if (pNMTVCD==NULL) { return -1; } switch (pNMTVCD->nmcd.dwDrawStage) { case CDDS_PREPAINT: { return (CDRF_NOTIFYPOSTPAINT | CDRF_NOTIFYITEMDRAW); } case CDDS_ITEMPREPAINT: { LOGFONT lf; lf.lfHeight = 20; lstrcpy(lf.lfFaceName, "Time New Roman"); lf.lfWeight = FW_HEAVY; lf.lfItalic = TRUE; HFONT gh = CreateFontIndirect(&lf);; SelectObject(pNMTVCD->nmcd.hdc, &gh); return (CDRF_NOTIFYPOSTPAINT | CDRF_NEWFONT); } case CDDS_ITEMPOSTPAINT: { LOGFONT lf; lf.lfHeight = 20; lf.lfItalic = TRUE; lstrcpy(lf.lfFaceName, "Time New Roman"); lf.lfWeight = FW_HEAVY; HFONT gh = CreateFontIndirect(&lf);; SelectObject(pNMTVCD->nmcd.hdc, &gh); return CDRF_DODEFAULT; //return (CDRF_NOTIFYPOSTPAINT | CDRF_NEWFONT); } } } return 0; }
Thank to everybody very much in advance..What do you mean they "do not work"? Why are you creating a new font every single time? Have you checked your return values? (specifically that of
CreateFontIndirect()
) --Mike-- LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD -
What do you mean they "do not work"? Why are you creating a new font every single time? Have you checked your return values? (specifically that of
CreateFontIndirect()
) --Mike-- LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD