Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » How to make CExtButton text initially bold Collapse All
Subject Author Date
Mark Walsen May 15, 2006 - 10:23 PM

A CExtButton, child of a CExtControlBar, does not display its text as bold until it has been clicked once. (Then it stays bold forever thereafter.) How can I make the button text to be displayed initially bold, so that there is no changing from normal to bold when it is clicked the first time.

Thanks!

-- Mark

Technical Support May 16, 2006 - 6:48 AM

Would you tell us how you set the button font?

Mark Walsen May 17, 2006 - 9:59 AM

The text is supplied to the CExtButton in its Create() function:

CString strButton = "Add";
rExtButton.Create(strButton, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON , CRect(0,0,0,0), this, nCtlID);

Cheers
-- Mark

Technical Support May 17, 2006 - 11:49 AM

We asked you to show how you set the button font, not text. Anyway, recently we found a bug in the CExtButton class that may cause the problem with the bold font. Please find the following lines in the ExtButton.cpp file:

_lf.lfWeight =

            ( m_nButtonType == BS_DEFPUSHBUTTON )

                        ? FW_BOLD

                        : FW_NORMAL;
And replace them with the following
if( m_nButtonType == BS_DEFPUSHBUTTON )

            _lf.lfWeight = 

                        (_lf.lfWeight > FW_BOLD) 

                                    ? _lf.lfWeight 

                                    : FW_BOLD;
Now you can set a custom font and the weight attribute will not be reset to FW_NORMAL.

Mark Walsen May 15, 2006 - 10:24 PM

(I forgot to set a checkmark next to ’Notify me when I get a reply’.)