1 ////////////////////////////////////////////////////////////////
2 // Copyright 1998 Paul DiLascia
3 // If this code works, it was written by Paul DiLascia.
4 // If not, I don't know who wrote it.
10 // This class fixes the sizing bugs in MFC that calculates the
11 // size of toolbars incorrectly for modern toobars (comctl32 version >= 4.71)
12 // It also contains a number of wrappers for function that CToolBar doesn't
13 // have (so you don't have to use GetToolBarCtrl).
15 // Generally, you should use CFlatToolBar instead of CFixMFCToolBar (even
16 // if you're not using the flat style), but you can use CFixMFCToolBar if
17 // all you want is the sizing fix for MFC tooblars.
19 class CTRL_EXT_CLASS CFixMFCToolBar : public CToolBar {
22 virtual ~CFixMFCToolBar();
24 static int iVerComCtl32; // version of commctl32.dll (eg 471)
26 // There is a bug in comctl32.dll, version 4.71+ that causes it to
27 // draw vertical separators in addition to horizontal ones, when the
28 // toolbar is vertically docked. If the toolbar has no dropdown buttons,
29 // this is not a problem because the separators are ignored when calculating
30 // the width of the toolbar. If, however, you have dropdown buttons, then the
31 // width of a vertically docked toolbar will be too narrow to show the
32 // dropdown arrow. This is in fact what happens in Visual Studio. If you
33 // want to show the dropdown arrow when vertical, set this to TRUE
36 BOOL m_bShowDropdownArrowWhenVertical;
38 virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
39 virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
41 CSize CalcLayout(DWORD nMode, int nLength = -1);
42 CSize CalcSize(TBBUTTON* pData, int nCount);
43 int WrapToolBar(TBBUTTON* pData, int nCount, int nWidth);
44 void SizeToolBar(TBBUTTON* pData, int nCount, int nLength,
46 virtual void OnBarStyleChange(DWORD dwOldStyle, DWORD dwNewStyle);
48 virtual CSize GetButtonSize(TBBUTTON* pData, int iButton);
50 // MFC has versions of these that are protected--but why?
52 void GetButton(int nIndex, TBBUTTON* pButton) const;
53 void SetButton(int nIndex, TBBUTTON* pButton);
56 LRESULT OnSizeHelper(CSize& sz, LPARAM lp);
57 afx_msg LRESULT OnSetBitmapSize(WPARAM, LPARAM);
58 afx_msg LRESULT OnSetButtonSize(WPARAM, LPARAM);
59 afx_msg LRESULT OnSettingChange(WPARAM, LPARAM);
61 DECLARE_DYNAMIC(CFixMFCToolBar)