none
GetOutputTextExtent is getting the string size smaller than printer out in Window 7 and 2008.

    Question

  • I use GetOutputTextExtent to get the string size and make sure it fit in my report template. The font and size of the string is setup before the print.

    On XP, the report prints fine with my string fits in the line.

    On Windows 7 and 2008, the last word is wrapped to the beginning of the next line and overlapped with starting word.

    I compared the line and found the print out in Windows 7 and 2008 is slightly larger than XP.

    Is there anyway I can get a more accurate size in Windows 7 and 2008. I am developing in MFC 6.

    Wednesday, August 14, 2013 1:37 PM

Answers

  • Hi,

    According to your description,the problem is that the string size is larger on Windows 7 and 2008 than on Windows XP when the text is printed.

    So what we need to do is to adjust the string size to Windows 7 and 2008.

    Please try the following suggestions:

    Construct a CFont object and attach a Windows font to it with CreateFont, CreateFontIndirect, CreatePointFont, or CreatePointFontIndirect, and then use the object's member functions to manipulate the font.

    Another possible solution is to use CWnd::GetFont to send the WM_GETFONT message to the window to retrieve the current font and then the CWnd::SetFont to send the WM_SETFONT message to the window to use the specified font.

    For more details,please refer to the following related topics:

    INFO: Correct Use of the SetFont() Function in MFC

    http://forums.codeguru.com/showthread.php?191608-Calculating-size-of-control-widow

    If your problem remains,please provide more details with drawing code for further analysis.

    Best Regards.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, August 19, 2013 3:50 AM

All replies

  • Hello,

    Thank you for your post.

    I am afraid that the issue is out of support range of VS General Question forum which mainly discusses WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System and Visual Studio Editor.

    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.

    Best regards,


    Amanda Zhu
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, August 16, 2013 1:27 AM
  • Hi,

    According to your description,the problem is that the string size is larger on Windows 7 and 2008 than on Windows XP when the text is printed.

    So what we need to do is to adjust the string size to Windows 7 and 2008.

    Please try the following suggestions:

    Construct a CFont object and attach a Windows font to it with CreateFont, CreateFontIndirect, CreatePointFont, or CreatePointFontIndirect, and then use the object's member functions to manipulate the font.

    Another possible solution is to use CWnd::GetFont to send the WM_GETFONT message to the window to retrieve the current font and then the CWnd::SetFont to send the WM_SETFONT message to the window to use the specified font.

    For more details,please refer to the following related topics:

    INFO: Correct Use of the SetFont() Function in MFC

    http://forums.codeguru.com/showthread.php?191608-Calculating-size-of-control-widow

    If your problem remains,please provide more details with drawing code for further analysis.

    Best Regards.

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, August 19, 2013 3:50 AM
  • Hi YanZheng,

    You haven't been here for several days,I wish everything goes well with you.

    Have you tried the solution proposed here and solved your problem?

    I will monitor this thread for another two days,however,for better managing the forum,I have to mark one reply as the answer two days later and if you think the answer marked doesn't help,please feel free to unmark it.

    If you sitll have questions unresolved,please consider posting another thread on the related forum to find out a better solution.

    Best Regards.

    Jane.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, August 22, 2013 12:59 AM