WM_SETFONT On ListView Works, But GetTextMetrics And GetTextExtentPoint32 Are Wrong.

Hi again folks:
   The user can use a dialog to set the font typeface, size and type (bold or italic) for a ListView in a dialog. 
   This works great by setting the user's choices in a LOGFONT and deriving a font handle, then sending the font handle to the ListView with a WM_SETFONT message. 
   The text of the header labels and the list are the selected font, size and type. 
   The problem is that I need to adjust the width of the columns.   The size returned from a call to GetTextExtentPoint32() or the average char width returned by a call to GetTextMetrics() appear to be the default sizes, and are unchanged
by the choices the user makes. 
   So the columns can be too small for the larger fonts in the ListView. 
   After setting the ListView fonts, I've tried the HDC from the ListView and the ListView's header.  GetTextExtentPoint32() and GetTextMetrics() are the same for either HDC, and seem to be unchanged by any choice made by the user. 
   So I can't adjust the column width for the new font. 
   What am I doing wrong?
      Thanks
      Larry

Thanks Dave:
   I'm guessing this is a common mistake. 
   I was under the impression that a device context created for a window, or control, would have the font used by that window. 
   After posting, I tried this simple experiment;
    SendMessage(listview_handle, WM_SETFONT, (WPARAM)control_font,
TRUE);
    listview_hdc = GetDC(listview_handle);
    SelectObject(listview_hdc, control_font);
    GetTextMetrics(listview_hdc, &tm);
    ReleaseDC(listview_handle, listview_hdc);
#ifdef _DEBUG
    HDC listview_dc2 = GetDC(listview_handle);    HFONT test_font = HFONT(SendMessage(listview_handle, WM_GETFONT,
0, 0));    HFONT old_font = HFONT(SelectObject(listview_dc2, test_font));
    DeleteObject(old_font);
    TEXTMETRIC test_tm2;
    GetTextMetrics (listview_dc2, &test_tm2) ;
#endif
   The GetTextMetrics() call in the ifdef clause delivered the wrong values until I added the WM_GETFONT and the SelectObject. 
   So I'm guessing I need to add those lines to any code that needs to know the dimensions of the font. 
   Is there some reason the device context doesn't know the font of the window used to create it? 
   I believe I can safely DeleteObject() on anything returned by SelectObject(), without damaging stock objects.  Is this correct? 
   Does Direct2D sidestep these issues, or will I still be contending with these GDI "features" if I move the the new interface? 
   I appreciate the time you have taken to assist me.
      Thanks
      Larry

Similar Messages

  • ITunesU works but Music and others are blank

    I have installed a new spyware tool called Spy Hunter but if iTunes U works should'nt the rest be ok? Could is somehow be a ratings things?
    Thanks

    Swedish, Swedish - Pro, Unicode hexinput and USA.
    So with the Swedish flag plus PRO in the "flag" menu at the top right of the Finder, what do you get when you type Alt + 2?
    If you do not have the "flag" menu, go to system prefs/language & text/input sources and check the box for "Show Input Menu in Finder."

  • I got my Iphone 3gs unlocked, but Navigation and Compass are not working. Please help if anybody had faced this problem and got it resolved.

    I got my Iphone 3gs unlocked, but Navigation and Compass are not working. Please help if anybody had faced this problem and got it resolved.

    Only the carrier that the iPhone was locked to can unlock. There you go, hacking void any support from this forum.

  • HT4587 My airport express and wireless airplay speaker are connected to wife, but airplay and homesharing are not working...what to do?

    My airport express and wireless airplay speaker are connected to WIFI, but airplay and homesharing are not working...what to do?  Everything was working fine until about two weeks ago, all of the sudden airplay has disappeared from the iphone, itunes on the laptop, and the apple remote for iphone.  I have restarted the router many times, re-setup the airplay speaker and the airport express and booth are showing as being properly connected to the router when I log into the router IP address.  I was on the phone with Apple support for 30 minutes they blames verizon, got on the phone with verizon and they stated the settings were all correct and compatible with apple, got back on the phone with apple and they again are blaming verizon and trying to get me to get an airport extreme because that would fix the problem...any suggestions, please!

    There are three Airport resets, soft, hard and factory default.  It would probably be beneficial if you tried each one in sequence.  Actually, you could jump to the factory default reset if you don't mind reconfiguring from scratch.

  • Just got a new iPad 2.  64 GB.  It will connect to wifi and facetime works, but email and internet won't connect.  Suggestions?  Thanks!

    Just got a new iPad 2.  It is 64 GB.  It will connect to wifi no problem and facetime works, but email and internet won't connect.
    Suggestions?
    Thanks!

    If facetime works, then the internet IS connecting.

  • Java works, but jar and javac don't

    java at the command line works, but jar and javac don't
    could it be the CLASSPATH
    I'm running Windows if that helps. If you need more info ask away
    Thanks
    CINC

    Definitely sounds like the classpath problem. From the sounds of the error message, you are using win95/98/ME, and so the best way to get around this is to set the classpath in your autoexec.bat file. I think the problem is because you have to set 2 variables in your path, one for the running of the java (JRE) and one for the tools to process the uncompiled files (SDK);
    rightclick on your autoexec.bat and select Edit
    here is my path, change yours accordingly so the paths lead to your windows, command and bin directories accordingly.
    PATH=D:\WINDOWS;D:\WINDOWS\COMMAND;D:\PROGRAM FILES\JAVASOFT\J2SDK1.4\BIN
    SET CLASSPATH=.;D:\PROGRAM FILES\JAVASOFT\J2SDK1.4\BIN\TOOLS.JAR
    Theres a section on setting classpath in This site at :
    java.sun.com/j2se/1.3/docs/tooldocs/win32/classpath.html
    and if that doesn't work, then i recommend you download and IDE which sorts ou most of these problems for you, and makes programming much easier also :)
    anything from:
    Suns Forte
    Jcreator
    Jbuilder
    to a real heavyweight which i use and find indispensible called Visual Age for Java, which is so powerful, but not for the faint hearted or weak-computered. :P
    Good Luck
    Benji

  • I have an external hard drive that shows up in disk utility but Verify and Restore are greyed out.

    I have an external hard drive that shows up in disk utility but Verify and Restore are greyed out. I am trying to determine what is wrong with the drive.
    I need the data on the drive and it won't show up in Disk Warrior. I have tried different Mac's and different USB cords only to find the same outcome. When selected in Disk Utility the information read as such...
    Disk Description : WD Elements 1023 Media                      Total Capacity : 500.11 GB (500,105,740,288 Bytes)
    Connection Bus : USB                                                               Write Status : Read/Write
    Connection Type : External                                                     S.M.A.R.T. Status : Not Supported
    USB Serial Number : 575837314135304D36373132        Partition Map Scheme : Unformatted
    As the drive shows in Disk Utility there must be some life left in it surely. There is a possibilty that the physical connection between the USB cord and the external drive is damaged but since the drive shows up I believe it's unlikely... before I give it to the pro's is there anything else I can do to diagnose the issue?

    Hello,
    I have just experienced the same thing!
    Although my external drive shows in Disk Utility, it does not show in Finder.
    And the Verify/Repair buttons are also greyed out.
    Also, although the drive is 2TB. DU shows it as having Total Capacity of only 4.14GB! (Which should be the Free Space).
    I was wondering if you solved your problem, & if so, would you share your solution.
    I´m afraid to Erase in case I lose all my Data on the drive.
    Thanks in advance for your reply!

  • I am trying to install flash player on my new Macpro hardrive.  It is downloaded but I get the continual message that my I.D. and password are wrong. Help please!

    I am trying to install my downloaded flash player on my new MacPro hard drive.  I get the continual message that my I.D. and password are wrong.  I know they are not wrong and have tried a lot of combinations from old Macs and old passwords too.  Nothing works.  How can I get the job done?

    Hi,
    On Mac, this password prompt is presented by your operating system, and is intended to keep you from accidentally installing software which can harm your system. Flash Player does not throw this prompt, Apple does that.
    Please provide machine credentials of currently logged in User to continue with the installation.
    Hope this helps.
    Thanks
    Piyush

  • I have set up iCloud for my iPhone, iPod, and macbook but photos and music are not downloading...

    I have set up iCloud for my iPhone, iPod, and macbook but photos and music are not downloading...
    ICloud preferences have been checked, photo stream enabled on iphone-- what's missing?

    The version that came with Microsoft Office Home and Business 2010 and says Version 14.0.7106.5003 (32 Bit) and the e-mail I have set up as POP / SMTP.  Thanks for your reply.

  • I change my apple id, so I deleted apps and downloaded again so I could update them but keynote and pages are expensive and I don't want to pay again for I pad and 2 laptops. Any suggestions?

    I change my apple ID and password. By doing that I was not able to update apps so I delete then and download them again. But keynote and pages are expensive.
    Is there any suggestions to send those apps to the new apple iD in iPad and 2 MacBooks ?

    Afraid not Hugo...  The apps purchased from one Apple ID account cannnot be transferred to another and accounts cannot be merged.
    Frequently asked questions about Apple ID

  • Trying to send a photo via e-mail from iPhoto.  But it says my e-mail and password are wrong and won't send and I don't know how to correct it.  Where do I go?

    Trying to send a photo via e-mail from iPhoto.  But it says my e-mail and password are wrong and won't send and I don't know how to correct it.  Where do I go?

    In the iPhoto preferences ==> accounts delete the account and re-enter it
    LN

  • Does the sprint unlocked iPhone works in Pakistan and what are the charges etc.

    Does the sprint unlocked iPhone works in Pakistan and what are the charges etc.

    Verizon iPhone 4S SIM UNLOCK Tutorial
    SGMD1 Oct 19, 2011 9:40 PM  
    Currently Being Moderated
    Verizon has confirmed (here and here) they WILL unlock the SIM on the iPhone 4S, allowing for use of local SIM cards while traveling abroad (no word yet on whether this will allow for use on AT&T and T-Mobile.) This is different than the jailbreak unlocking method; SIM unlocking through Verizon is permanent and will not affect your warranty in any way.
    1. Meet the following requirements:
    * Must be a Verizon Wireless customer.
    * The iPhone 4S being unlocked must be active on a Verizon Wireless line of service.
    * The line of service must be active at least 60 days.
    * The line of service must be in good standing for the past 60 days.
    * Only one SIM Unlock per line every 10 months.
    If you don't meet one or more of the above requirements, call anyway. You may still get lucky.
    2. Insert a foreign SIM into the SIM card slot on the side of your phone (only required to confirm that the unlock is successful.)
    3. Call 1-800-711-8300 (Verizon Global Support) and ask the representative for a SIM unlock. Occassionally a representative may not know exactly what you are referring to; make sure you are not transferred to a different department. You are in the right place. Explain that they should have a walkthrough on how to do this, and that it allows for the use of local, non-Verizon SIM cards while traveling abroad.
    4. Get confirmation from the rep that the unlock has been applied to your account, then check your phone to make sure it recognizes your SIM and can connect (if successful it will roam on AT&T, assuming you are calling from the USA.) You will NOT see an unlock confirmation in iTunes as that is for a factory-applied unlock only.
    5. Enjoy your new unlocked iPhone 4S!
    ****ALSO I JUST SPOKE WITH NICHOLE (VZN GLOBAL SUPPORT) REGARDING IF THE IPHONE 4S HAS TO BE ACTIVE AFTER SIM UNLOCK AND THE ANSWER IS: NO!

  • IMac indicating Password for Gmail is incorrect but iPhone and iPad are both able to connect to gmail account....how do I correct this on the iMac?

    iMac indicating Password for Gmail is incorrect but iPhone and iPad are both able to connect to gmail account....how do I correct this on the iMac?

    Try This:
    Open up the imessage app on your Imac.  Once you have it opened go to top left corner of your screen next to the apple picture and the word MESSAGES appears. Click on it then click on preferences and uncheck your husbands phone and number and or any other numbers which are checked. I had same problem this fixed it. Also if you wanted to you can open up your own Apple account, but that's not really necessary. My wife and I both share the same as you do

  • Date and time are wrong

    My date and time are wrong on boot up and won't adjust back to normal automatically.  I think the internet is telling me it's a problem with either my PRAM or CMOS or NVRAM battery, the little guy that holds info while the big guy is tapped.  I want to replace this. Is that possible?  What is the battery actually called?

    Hey MisterW,
    Thanks for the question. It sounds like you wish to reset your PRAM/NVRAM, the following article should assist you:
    About NVRAM and PRAM
    http://support.apple.com/kb/HT1379
    Thanks,
    Matt M.

  • I'm trying to change my password. I'm being asked to answer two questions to verify my identity, but apparently my answers are wrong. Can't I be asked other questions, or find other ways to prove my identity?

    I'm trying to change my password. I'm being asked to answer two questions to verify my identity, but apparently my answers are wrong. Can't I be asked other questions, or find other ways to prove my identity?

    I'm trying to change my password also - but can't even find a link in itunes for "change password", help?

Maybe you are looking for