我在Resource文件中编写了一个Toolbar,然后在一个Dialog中调用m_toolbar.Create()函数创建该Toolbar,并用LoadToolbar()函数,读入刚才在Resource文件中编写的Toolbar。同时,我调用了SetButtonText函数为按钮添加文字(就是文字会显示在图标下面),可是奇怪的是,显示的只有上面一半,没办法全部显示。调用了Toolbar的SetHeight和SetSize函数,都没有用,现在实在是没有办法了。高手帮忙啊。还有,就是它显示了Toolbar,但是都是暗的,没办法按,即使对按钮添加了COMMAND响应函数,还是暗的,怎么才能让其变成Enabled呢?谢谢!
{
TRACE0("Failed to Create Dialog Toolbar\n");
EndDialog(IDCANCEL);
} CRect rcClientOld; // 久客户区RECT
CRect rcClientNew; // 加入TOOLBAR后的CLIENT RECT
GetClientRect(rcClientOld); //
// Called to reposition and resize control bars in the client area of a window
// The reposQuery FLAG does not really traw the Toolbar. It only does the calculations.
// And puts the new ClientRect values in rcClientNew so we can do the rest of the Math.
//重新计算RECT大小
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,
AFX_IDW_CONTROLBAR_LAST,
0,
reposQuery,
rcClientNew); // All of the Child Windows (Controls) now need to be moved so the Tollbar does not cover them up.
//所有的子窗口将被移动,以免被TOOLBAR覆盖
// Offest to move all child controls after adding Tollbar
//计算移动的距离
CPoint ptOffset(rcClientNew.left-rcClientOld.left,
rcClientNew.top-rcClientOld.top); CRect rcChild;
CWnd* pwndChild = GetWindow(GW_CHILD); //得到子窗口
while(pwndChild) // 处理所有子窗口
{//移动所有子窗口
pwndChild->GetWindowRect(rcChild);
ScreenToClient(rcChild);
rcChild.OffsetRect(ptOffset);
pwndChild->MoveWindow(rcChild,FALSE);
pwndChild = pwndChild->GetNextWindow();
} CRect rcWindow;
GetWindowRect(rcWindow); // 得到对话框RECT
rcWindow.right += rcClientOld.Width() - rcClientNew.Width(); // 修改对话框尺寸
rcWindow.bottom += rcClientOld.Height() - rcClientNew.Height();
MoveWindow(rcWindow,FALSE); // Redraw Window RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);