CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Window text content and its size

  1. #1
    Join Date
    May 2008

    Question Window text content and its size

    I'd like to programmatically reset layout for my windows that contains mainly text via a call as SetWindowText.
    I can draw only a single line of text without any types of text formats included;
    that is,
    I can not display, for example, 2 lines of text as the second line is gone below the window area,

    Thank you.///

  2. #2
    Join Date
    Nov 2002

    Re: Window text content and its size

    I think you are asking how to draw text for a multi-line title in the window's caption region.

    This is a complicated process that involves handling of the WM_NCPAINT message. And this already-complicated process has become even more complicated since Vista, and the introduction of DWM composition (Desktop Window Manager) and the DWM API. DWM is the thing responsible for the Aero/glass look in Vista and above.

    For a pre-Vista article on the topic, see "Custom Captions (including multi-line captions)" at http://www.codeproject.com/KB/GDI/customcaption.aspx . The code from that article might not work with DWM.

    For another pre-Vista article, see Paul DiLascia's C++ Q&A from MSJ issue of June 1997: http://www.microsoft.com/msj/0697/c0697.aspx

    In both of the above cases, it is necessary to handle WM_NCACTIVATE, WM_SETTEXT, WM_NCPAINT and many others. And again, post-Vista, it might not work anymore.

    If you are targetting post-Vista systems, you might try using some of the newer DWM APIs. One article in Microsoft that seems pertinent is "Custom Window Frame Using DWM" at http://msdn.microsoft.com/en-us/libr...(v=VS.85).aspx . The article uses the DwmExtendFrameIntoClientArea function to extend the frame into the client area, thereby permitting drawing of your own text into the caption frame.

    Good luck.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)