المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Setting a CToolBar Button's Label to take multiple lines of text



C++ Programming
03-03-2010, 01:51 PM
I've been trying to figure out how to get the buttons on a CToolBar to accept the newline character like a normal button does when you set the multiple line property to true.
Apparently the buttons on a toolbar are not normal buttons so i cant get a handle and there is no multiline style like there is on a normal button.

I've got (this is in a class that inherits CToolBar)

CToolBarCtrl& bar = GetToolBarCtrl();//CToolBar::GetToolBarCrtl
int nIndex = 0;
CRect NoTextRc( 0, 0, 0, 0 );
bar.GetItemRect( 0, NoTextRc );
bar.SetMaxTextRows(3);//sets the max number of rows
bar.SetDrawTextFlags( 0xffffffff, DT_WORDBREAK);//Should Break line on space and /n

Line 1 gets the toolbarctrl for the toolbar in question
Line 5&6 should make me able to have 3 rows of text and break on a space or a carriage return
What it is doing is just not displaying any text after the space or the /n.
I've made the size of the button really large just incase the button wasn't big enough with

SetSizes(CSize( 120, 100 ), CSize( 90, 36 ));//CToolBar::SetSize

Here is where i set the text of the toolbar
The commented code are failed attempts at making the button multiline in the same mannar as a button

if ( !strButtonText.IsEmpty() )
{
//SetButtonStyle(nIndex,ES_MULTILINE);
strButtonText.Replace(" ","\r");
//bar.SetStyle(ES_MULTILINE);
SetButtonText( nIndex, strButtonText );//CToolBar::SetButtonText
}

All the above is in a class that inherits CToolBar.
Can anyone please help me out here i've spent way more time than i should on this and i have no solution in sight.