Print Page | Close Window

Fit text to CXTPButton with image

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=12932
Printed Date: 16 June 2024 at 7:08am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Fit text to CXTPButton with image
Posted By: ibmldev
Subject: Fit text to CXTPButton with image
Date 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




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net