-
September 21st, 2013, 07:50 AM
#1
How to use BTNS_AUTOSIZE
I want to control my toolbar dynamically.
First I added tool bar with style including TBSTYLE_EX_MIXEDBUTTONS | TBSTYLE_LIST.
Then added the tool bar to a rebar. I added tool tips by handling TTN_GETDISPINFO.
Everything works fine. But when I try to add text to right of the button, the text
gets added but button size is not automatically changing.
The following code is not working .
void SetToolbarText(HWND& hwndToolbar,LPTSTR szText)
{
ATLASSERT(::IsWindow(hwndToolbar));
TBBUTTONINFO tbbi = { 0 };
tbbi.cbSize = sizeof(TBBUTTONINFO);
tbbi.dwMask = TBIF_TEXT;// | TBIF_SIZE;//if I add TBIF_SIZE code will work!
tbbi.cchText = 0;
tbbi.cx = 200;
tbbi.fsState = 0;
tbbi.fsStyle = tbbi.fsStyle | BTNS_SHOWTEXT | BTNS_AUTOSIZE ;//TBSTYLE_AUTOSIZE
//tbbi.fsStyle = tbbi.fsStyle | BTNS_SHOWTEXT | TBSTYLE_AUTOSIZE ;//TBSTYLE_AUTOSIZE
tbbi.idCommand = 0;
tbbi.iImage = 0;
tbbi.lParam = 0;
tbbi.pszText = szText;//szText is _T("ABC")
BOOL b = (BOOL)::SendMessage(hwndToolbar, TB_SETBUTTONINFO, ID_BUTTON3, (LPARAM)&tbbi);
return;
}
Can anybody please help me?
-
September 24th, 2013, 03:38 AM
#2
Re: How to use BTNS_AUTOSIZE
you need to add TBIF_STYLE to the mask if you want to change the fsStyle value to contain the AUTOSIZE flag
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
|