关于对话框的工具栏问题!
功名半纸 博客专家认证 2002-04-25 06:44:30 不知道怎么回事!我对话框的工具栏所有按钮全部成为了一组了!而我并没有设置其属性!
代码如下:
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBarEx(IDR_EDIT_SCRIPT))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// m_wndToolBar.ModifyStyle(0,TBSTYLE_FLAT);
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
DWORD dwStyle = m_wndToolBar.GetButtonStyle(m_wndToolBar.CommandToIndex(ID_EDIT_FONT));
dwStyle |= TBSTYLE_DROPDOWN;
m_wndToolBar.SetButtonStyle(m_wndToolBar.CommandToIndex(ID_EDIT_FONT), dwStyle);
dwStyle = m_wndToolBar.GetButtonStyle(m_wndToolBar.CommandToIndex(ID_EDIT_SAVE));
CRect rcClientNow,rcClientStart;
GetClientRect(rcClientStart);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,
0, reposQuery, rcClientNow);
CPoint ptOffset(rcClientNow.left - rcClientStart.left,rcClientNow.top - rcClientStart.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();
}
// adjust the dialog window dimensions
CRect rcWindow;
GetWindowRect(rcWindow);
rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
MoveWindow(rcWindow, false);// and position the control bars
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST, 0);
m_wndToolBar是我重载的一个工具栏类!