Ownerdraw Listview and new Font

This is a discussion on Ownerdraw Listview and new Font within the Windows Programming forums, part of the Platform Specific Boards category; I have changed the font in my ownerdraw Listview (created on the fly in MSVC v6 C no ++). In ...

  1. #1
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856

    Ownerdraw Listview and new Font

    I have changed the font in my ownerdraw Listview (created on the fly in MSVC v6 C no ++).

    In the WM_DRAWITEM I get a row, do the drawing, then the next row is a seperate message.

    I take each columns sub items rect and fill it the correct colour. Then I get the text and test its size to center the text. No problems here.

    Trouble is with the height. The new font is bigger, to make the ctrl more readable.

    Unfortunately the item rectangle in the DRAWITEM struct is sized for the smaller original font but the HDC has the larger font already selected in.

    This means the text will not fit in the items rectangle (and onto the HDC) as it is too high.

    This results in only the top of the text being drawn (as the rest will not fit on the HDC).

    If I turn the ownerdraw off windows draws the listview with the new font and no colour. So it must be possible.



    How do I change each item (or rows) height?

    Any other ideas or links to ownerdraw or custom draw stuff.

    Thanks.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Don't know if you've investigated NM_CUSTOMDRAW yet but it seems to offer the facility you require (COMCTL32.DLL v5.8 required) and some kind of explanation for the font clipping. There also seems to be an example that may be of some interest to you.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,856
    Thanks Ken, appreciate the help.



    I love it when I get into an error MS considers "is necessary for backward compatibility with earlier versions of the common controls."

    So I am going to go back from owner draw to custom draw to fix this error when MSDN says
    "Your application can harness custom draw notifications to easily change the font used to display items or manually draw an item without having to do a full-blown owner draw. "

    LOL!
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21