Thread: DRAWITEMSTRUCT confusion.

  1. #1
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708

    DRAWITEMSTRUCT confusion.

    I am trying to get different fonts into a combobox. I have a pointer to the DRAWITEMSTRUCT, but I'm not sure what to do with it! Do I need to draw the text to an HDC, and blit it via the pointer's HDC? But then how will the user select the text normally? I'm just not sure how to go about this - even though I've read a lot of documentation about it, very unsure...any help appreciated.

    [edit]

    Ok. I have all that sorted out now. Now my problem is that I want to signal to Windows that the user is changing fonts so that I can update the measure of each item. I tried sending a CB_SETITEMDATA message, etc, but this obviously isn't the way. Any ideas?
    Last edited by Sebastiani; 12-08-2002 at 10:58 PM.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    How does the user change fonts?

    that is once you know the users font selection, call for a paint and then use the new font size.
    "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

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    I get the font from a CHOOSEFONT structure passed to the ChooseFont dialog function. The painting is simple. Problem is, when the user changes fonts, the underlying "virtual" text in the combobox still measures the size of the old font. So let's say the user chooses a font that it twice the old font height. After I update the view, the user expects to be able to click a line and have that text pop up into the combobox's edit control. Instead, they click on line #4, but get line #8 because the old font was smaller!

    Initially, when the combobox is created, Windows gets the dimensions of the virtual text when you respond to the WM_MEASUREITEM message, (filling in a MEASUREITEMSTRUCT it passes you).

    So basically, I need to stimulate Windows to send a WM_MEASUREITEM message whenever the font changes...
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer confusion
    By rits in forum C Programming
    Replies: 3
    Last Post: 03-12-2009, 08:00 AM
  2. Terrible confusion with time variables
    By LowlyIntern in forum C++ Programming
    Replies: 12
    Last Post: 08-01-2008, 07:23 AM
  3. C++ Classes: Use, Misuse...Confusion.
    By Snorpy_Py in forum C++ Programming
    Replies: 4
    Last Post: 10-23-2006, 01:46 AM
  4. for loop confusion
    By Enges in forum C++ Programming
    Replies: 6
    Last Post: 04-26-2006, 08:21 AM
  5. confusion with increment and decrement operators
    By cBegginer in forum C Programming
    Replies: 6
    Last Post: 03-19-2005, 03:45 PM