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);
}
上面的代码显示没有文本的工具栏。要做什么来获取 在运行时将工具栏从一个位置移动到另一个位置而不是第一次时显示的文本:(
答案 0 :(得分:0)
我认为这只是一个问题:
myBar.SetWindowText( _T( "Window Title goes here" ) );