Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Fit text to CXTPButton with image
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Fit text to CXTPButton with image

 Post Reply Post Reply
Author
Message
ibmldev View Drop Down
Groupie
Groupie


Joined: 17 October 2006
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote ibmldev Quote  Post ReplyReply Direct Link To This Post Topic: Fit text to CXTPButton with image
    Posted: 15 December 2008 at 10:36am
If I make a CXTPButton with image and text, and the text is too long to fit in the button, then the text is trunctated to fit (as expected). But, the button does not reserve space for the image. As a result, the text fills the entire width of the button and the image sits on top of the text, obscuring part of it.

It would be nice if the text were not only clipped to fit the button, but also clipped to fit the non-image portion of the button. Can this be done automatically, or do I need to somehow manually trim the text to some appropriate length when the button is resized? If I need to do it, do you have any tips to offer?

Here is the code I use to create the button:

        m_btn.Create( _T( "Foo - Now is the time for all good men to come to the aid of their country." ), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_PUSHLIKE, dummyRect, this, ID_LED );
        m_btn.SetChecked( FALSE );
        m_btn.SetShowFocus( FALSE );
        m_btn.SetBitmap( 0, IDB_RED_LED_16X16 );
        m_btn.SetImageAlignment( BS_VCENTER | BS_LEFT );
        m_btn.SetTextImageRelation( xtpButtonImageBeforeText );

This button is resized by the application when the dialog containing it is resized, so the amount of spaced available may vary after creation.

-Mark

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.