在对话框上建立真彩工具栏不能用在框架上建立真彩按钮的方法, 最近在MSDN上找到答案,微软提出的方案是除了需要在框架上建立真彩按钮的代码外,还要做的工作就是将对话框上所有的窗口整体下移一段,目的是为真彩按钮腾出地方来,其中窗口移动的代码是这样的,可以放在ADDBAR之后
CRect rcClientOld;
CRect rcClientNew;
GetClientRect(rcClientOld);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0,reposQuery,
rcClientNew);
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);
rcWindow.right+=rcClientOld.Width()-rcClientNew.Width();//移动前和移动后的差值就是工具栏的宽度和长度
rcWindow.bottom+=rcClientOld.Height()-rcClientNew.Height();
MoveWindow(rcWindow,FALSE);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);