Article ID: 201009
Article Last Modified on 11/21/2006
119591 How to Obtain Microsoft Support Files from Online Services
File Name Size --------------------------------------------------------- WrapFixedToolBar.h, Implement the CToolBar-derived class WrapFixedToolBar.cpp that would provide the desired behavior. WrapToolBar.h The main header file (CWrapToolBarApp class). WrapToolBar.cpp The main application source file. WrapToolBar.rc Listing of all Windows resources used. res\WrapToolBar.ico Icon file. res\WrapToolBar.rc2 Resources not edited by the IDE. WrapToolBar.clw Information used by ClassWizard. MainFrm.h, MainFrm.cpp The frame class CMainFrame. res\Toolbar.bmp Used to create tiled images for the toolbar. WrapToolBarDoc.h, WrapToolBarDoc.cpp The document CWrapToolBarDoc. WrapToolBarView.h, WrapToolBarView.cpp The view of the document. StdAfx.h, StdAfx.cpp Used to build a precompiled header (PCH) file. Resource.h Defines new resource IDs.
LRESULT CWrapFixedToolBar::OnSizeParent(WPARAM, LPARAM lParam)
{
AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam;
DWORD dwStyle = RecalcDelayShow(lpLayout);
if ((dwStyle & WS_VISIBLE) && (dwStyle & CBRS_ALIGN_ANY) != 0)
{
CRect rect;
rect.CopyRect(&lpLayout->rect);
// Reposition buttons on toolbar according to available space.
SetWidth(rect.Width());
// Pass message processing to base class handler.
CToolBar::OnSizeParent(0, lParam);
}
return 0;
}
void CWrapFixedToolBar::SetWidth(long lWidth)
{
TBBUTTON* pData;
// Read the toolbar buttons.
int nCount = GetToolBarCtrl().GetButtonCount();
if (nCount != 0)
{
pData = new TBBUTTON[nCount];
for (int i = 0; i < nCount; i++)
_GetButton(i, &pData[i]);
}
else
return;
// Get the toolbar buttons offsets in the toolbar area.
CRect rect;
rect.SetRectEmpty();
CalcInsideRect(rect, TRUE);
// Wrap buttons according to available space.
WrapToolBar(pData, nCount, lWidth - abs(rect.Width()));
// Save toolbar buttons to underlying toolbar control.
if (nCount != 0)
for (int i = 0; i < nCount; i++)
_SetButton(i, &pData[i]);
if (pData)
delete [] pData;
}
Keywords: kbfile kbhowto kbsample kbtoolbar KB201009