int MFC_Tutorial_Window::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!myBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC))
{
MessageBox(L"Failed to create toolbar\n");
return -1; // fail to create
}
CImageList img;
CString str;
myBar.GetToolBarCtrl().SetButtonWidth(150,250);
myBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
bool b = img.Create(IDB_COLDBITMAP, 22, 0, RGB(255, 0, 255));
myBar.GetToolBarCtrl().SetHotImageList(&img);
//img.Detach();
myBar.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
myBar.SetButtons(NULL, 5);
myBar.SetButtonInfo(0, IDB_BITMAP1, TBSTYLE_BUTTON |TBSTYLE_DROPDOWN |TBBS_AUTOSIZE , 0);
b = myBar.SetButtonText(0,L"ABC");
myBar.SetSizes(CSize(42,38),CSize(16,15));
myBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&myBar);
}
上面的代码显示了没有文本的工具栏。
当我在运行时将工具栏从一个位置移到另一个位置但不是第一次时显示的文本:(
最佳答案
我相信这只是要做的事情:
myBar.SetWindowText( _T( "Window Title goes here" ) );