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. Listview Custom Draw

Listview Custom Draw

Scheduled Pinned Locked Moved C / C++ / MFC
9 Posts 3 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.
  • P Offline
    P Offline
    Paul C
    wrote on last edited by
    #1

    Anyone know how to determine the font that a custom draw listview item is using?

    R T 2 Replies Last reply
    0
    • P Paul C

      Anyone know how to determine the font that a custom draw listview item is using?

      R Offline
      R Offline
      realJSOP
      wrote on last edited by
      #2

      In the OnInitialUpdate function, you could call GetFont() and then analyze the members of the pointer it returns (CFont*). Something like this:

      CFont* font = GetFont();
      if (font)
      {
      LOGFONT lf;
      font->GetLogFont(&lf);
      TRACE("Typeface name of font = %s\n", lf.lfFaceName);
      }

      To hell with those thin-skinned pillow-biters. - Me, 10/03/2001

      P 1 Reply Last reply
      0
      • R realJSOP

        In the OnInitialUpdate function, you could call GetFont() and then analyze the members of the pointer it returns (CFont*). Something like this:

        CFont* font = GetFont();
        if (font)
        {
        LOGFONT lf;
        font->GetLogFont(&lf);
        TRACE("Typeface name of font = %s\n", lf.lfFaceName);
        }

        To hell with those thin-skinned pillow-biters. - Me, 10/03/2001

        P Offline
        P Offline
        Paul C
        wrote on last edited by
        #3

        I am not using MFC so how would I do this just using the windows API? I am actually trying to determine whether the item is bold or not in the Outlook Express message list. Thank you for your response.

        R 1 Reply Last reply
        0
        • P Paul C

          Anyone know how to determine the font that a custom draw listview item is using?

          T Offline
          T Offline
          Tomasz Sowinski
          wrote on last edited by
          #4

          Custom-draw listview is free to choose as many fonts as it wants for painting different parts of the item area (in such case it skips the default drawing completely). Are you subclassing the listview in question? Tomasz Sowinski -- http://www.shooltz.com

          P 1 Reply Last reply
          0
          • T Tomasz Sowinski

            Custom-draw listview is free to choose as many fonts as it wants for painting different parts of the item area (in such case it skips the default drawing completely). Are you subclassing the listview in question? Tomasz Sowinski -- http://www.shooltz.com

            P Offline
            P Offline
            Paul C
            wrote on last edited by
            #5

            No I am not subclassing the listview but using hooks.

            T 1 Reply Last reply
            0
            • P Paul C

              I am not using MFC so how would I do this just using the windows API? I am actually trying to determine whether the item is bold or not in the Outlook Express message list. Thank you for your response.

              R Offline
              R Offline
              realJSOP
              wrote on last edited by
              #6

              WM_GETFONT An application sends a WM_GETFONT message to a control to retrieve the font with which the control is currently drawing its text. To send this message, call the SendMessage function with the following parameters. SendMessage( (HWND) hWnd, // handle to destination window WM_GETFONT, // message to send (WPARAM) wParam, // not used; must be zero (LPARAM) lParam // not used; must be zero ); Parameters This message has no parameters. Return Values The return value is a handle to the font used by the control, or NULL if the control is using the system font. Requirements Windows NT/2000 or later: Requires Windows NT 3.1 or later. Windows 95/98/Me: Requires Windows 95 or later. Header: Declared in Winuser.h; include Windows.h. After you get the HFONT, you can probably build a logfont to retrieve the info. To hell with those thin-skinned pillow-biters. - Me, 10/03/2001

              P 1 Reply Last reply
              0
              • P Paul C

                No I am not subclassing the listview but using hooks.

                T Offline
                T Offline
                Tomasz Sowinski
                wrote on last edited by
                #7

                Well, assuming that this control only sets the font and lets COMCTL32 draw the items, you may try to install WH_CALLWNDPROCRET hook and inspect the font selected into DC after NM_CUSTOMDRAW. You'll have to check for correct custom-draw stage, probably CDDS_ITEMPREPAINT. BTW: why do you need this functionality? Tomasz Sowinski -- http://www.shooltz.com

                P 1 Reply Last reply
                0
                • R realJSOP

                  WM_GETFONT An application sends a WM_GETFONT message to a control to retrieve the font with which the control is currently drawing its text. To send this message, call the SendMessage function with the following parameters. SendMessage( (HWND) hWnd, // handle to destination window WM_GETFONT, // message to send (WPARAM) wParam, // not used; must be zero (LPARAM) lParam // not used; must be zero ); Parameters This message has no parameters. Return Values The return value is a handle to the font used by the control, or NULL if the control is using the system font. Requirements Windows NT/2000 or later: Requires Windows NT 3.1 or later. Windows 95/98/Me: Requires Windows 95 or later. Header: Declared in Winuser.h; include Windows.h. After you get the HFONT, you can probably build a logfont to retrieve the info. To hell with those thin-skinned pillow-biters. - Me, 10/03/2001

                  P Offline
                  P Offline
                  Paul C
                  wrote on last edited by
                  #8

                  That method will return the listview font not the font of the item.

                  1 Reply Last reply
                  0
                  • T Tomasz Sowinski

                    Well, assuming that this control only sets the font and lets COMCTL32 draw the items, you may try to install WH_CALLWNDPROCRET hook and inspect the font selected into DC after NM_CUSTOMDRAW. You'll have to check for correct custom-draw stage, probably CDDS_ITEMPREPAINT. BTW: why do you need this functionality? Tomasz Sowinski -- http://www.shooltz.com

                    P Offline
                    P Offline
                    Paul C
                    wrote on last edited by
                    #9

                    I was hoping there was an easier way. Thanks for your help :)

                    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