CRect rectClientStart;
CRect rectClientNow;
//make the rectClientStart bigger than rectClientNow
pParentWnd->GetClientRect(rectClientStart);
pParentWnd->RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0,reposQuery,rectClientNow);
//shift the position of all the control
CPoint ptOffset(rectClientNow.left-rectClientStart.left,rectClientNow.top-rectClientStart.top);
CRect rectChild;
CWnd *pWndChild=pParentWnd->GetWindow(GW_CHILD);
while(pWndChild)
{
pWndChild->GetWindowRect(rectChild);
pParentWnd->ScreenToClient(rectChild);
rectChild.OffsetRect(ptOffset);
pWndChild->MoveWindow(rectChild,false);
pWndChild=pWndChild->GetNextWindow();
}
//enlarge the size of the dialog
CRect rectWindow;
pParentWnd->GetWindowRect(rectWindow);
rectWindow.right+=rectClientStart.Width()-rectClientNow.Width();
rectWindow.bottom+=rectClientStart.Height()-rectClientNow.Height();
pParentWnd->MoveWindow(rectWindow,false);
//set the proper postion of the toolbar!
pParentWnd->RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
pParentWnd->CenterWindow();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
if (!m_wndToolBar1.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar1.LoadToolBar(IDR_TOOLBAR_DIALOG))
{
TRACE0("Failed to create toolbar\n");
EndDialog(IDCANCEL);// fail to create
}
if (!m_wndToolBar24Bit.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar24Bit.LoadToolBar(IDR_TOOLBAR_NAVIGATE))
{
TRACE0("Failed to create toolbar\n");
EndDialog(IDCANCEL);// fail to create
}
// Screen designer control bar
if (!m_wndDynControlBar.CreateEx(this) ||
!m_wndDynControlBar.LoadToolBar(IDR_DYNCONTROLBAR))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this)//, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM)
|| !m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return FALSE; // fail to create
}
// Set up hot bar image lists.
CImageList imageList;
CBitmap bitmap;
// Create and set the normal toolbar image list.
bitmap.LoadBitmap(IDB_NAVIGATE_COLD);
imageList.Create(21, 20, ILC_COLORDDB|ILC_MASK, 6, 1);
imageList.Add(&bitmap, RGB(255,0,255));
m_wndToolBar24Bit.SendMessage(TB_SETIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
imageList.Detach();
bitmap.Detach();
// Create and set the hot toolbar image list.
bitmap.LoadBitmap(IDB_NAVIGATE_HOT);
imageList.Create(21, 20, ILC_COLORDDB|ILC_MASK, 6, 1);
imageList.Add(&bitmap, RGB(255,0,255));
m_wndToolBar24Bit.SendMessage(TB_SETHOTIMAGELIST, 0, (LPARAM)imageList.m_hImageList);
imageList.Detach();
bitmap.Detach();
//repostion the toolbar
this->RecalToolBarPos(this);
return TRUE; // return TRUE unless you set the focus to a control
}