-
February 19th, 2011, 08:27 AM
#1
MFC: Buttonstyles and Windows 7
Hi,
My MFC dialog app which was working ok in XP has started exhibiting some strange behaviour concerning MFC buttons.
I have a function to set the button text and style, but bizarrely, when the text is too long to fit the button and is wrapped, the button seems to 'forget' the BS_CENTER attribute and left aligns.
I should say that I'm using the "classic" style with the Themes services deactived. Even if this is avtivated, the behaviour is the same. If I go back to Windows 7 themes, then the button text centers correctly, but this isn't the look I want.
Any idea how to get the buttons to behave properly in Classic theme in Win7?
This is my code:
Code:
void CMain::SetButtonText(CWnd* ptr, std::string button_text )
{
int test = 0;
test = ptr->ModifyStyle(0, BS_MULTILINE , 0);
test = ptr->ModifyStyle(0, BS_CENTER, 0 );
ptr->SetWindowText(_T(button_text.c_str()));
}
When I debug step by step, ModifyStyle returns TRUE, and the std::string is correct (no white spaces).
Also, when I comment out the style setting and use the VS button properties, the result is the same.
Any ideas? Or is this a limitation of Windows 7? (I'm beginning to think it is).
Thanks.
-
February 20th, 2011, 12:08 PM
#2
Re: MFC: Buttonstyles and Windows 7
AFAIK, in classic theme, BS_CENTER is ignored if BS_MULTILINE is set, regardless the Windows version.
-
February 22nd, 2011, 02:31 PM
#3
Re: MFC: Buttonstyles and Windows 7
In XP with classic theme, it works as expected. ie. button text centered when BS_CENTER and BS_MULTILINE is set.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|