Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Fonts for CTreeCtrl. What is not right now?

Fonts for CTreeCtrl. What is not right now?

Scheduled Pinned Locked Moved C / C++ / MFC
questiondata-structureshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bilas
    wrote on last edited by
    #1

    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..

    M 1 Reply Last reply
    0
    • B bilas

      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..

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • M Michael Dunn

        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

        B Offline
        B Offline
        bilas
        wrote on last edited by
        #3

        You are right. I simply tried to create font every time. I'll do it another way, now I only want it to work.:^)

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups