home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 21 / IOPROG_21.ISO / SOFT / DEMOT.ZIP / Src / Include / FlatBar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-23  |  3.8 KB  |  129 lines

  1. ////////////////////////////////////////////////////////////////
  2. // CFlatToolBar 1997 Microsoft Systems Journal. 
  3. // If this code works, it was written by Paul DiLascia.
  4. // If not, I don't know who wrote it.
  5. // This code compiles with Visual C++ 5.0 on Windows 95
  6. //
  7.  
  8. #if !defined(FLATBAR_H_INCLUDED)
  9. #define FLATBAR_H_INCLUDED
  10.  
  11. #if _MSC_VER >= 1000
  12. #pragma once
  13. #endif // _MSC_VER >= 1000
  14.  
  15. // Old commctrl.h compatibility *** Kirk Stowell
  16. #if !defined (TB_SETEXTENDEDSTYLE)
  17. #define TB_SETEXTENDEDSTYLE (WM_USER+84)
  18. #endif
  19.  
  20. #if !defined (TB_SETHOTIMAGELIST)
  21. #define TB_SETHOTIMAGELIST (WM_USER+52) 
  22. #endif
  23.  
  24. #if !defined (TB_SETIMAGELIST)
  25. #define TB_SETIMAGELIST (WM_USER+48)
  26. #endif
  27.  
  28. #if !defined (TBSTYLE_TRANSPARENT)
  29. #define TBSTYLE_TRANSPARENT 0x8000
  30. #endif
  31.  
  32. #if !defined (TBSTYLE_AUTOSIZE)
  33. #define TBSTYLE_AUTOSIZE 0x0010
  34. #endif
  35.  
  36. #if !defined (TBSTYLE_EX_DRAWDDARROWS)
  37. #define TBSTYLE_EX_DRAWDDARROWS 0x00000001
  38. #endif
  39.  
  40. #if !defined (TBSTYLE_FLAT)
  41. #define TBSTYLE_FLAT 0x0800
  42. #endif
  43.  
  44. //////////////////
  45. // "Flat" style tool bar. Use instead of CToolBar in your CMainFrame
  46. // or other window to create a tool bar with the flat look.
  47. //
  48. // CFlatToolBar fixes the display bug described in the article. It also has
  49. // overridden load functions that modify the style to TBSTYLE_FLAT. If you
  50. // don't create your toolbar by loading it from a resource, you should call
  51. // ModifyStyle(0, TBSTYLE_FLAT) yourself.
  52. //
  53.  
  54. class CLASS_EXPORT CFlatToolBar : public CToolBar {
  55.  
  56.     DECLARE_DYNAMIC(CFlatToolBar)
  57.  
  58. ////////////////////////////////////////////////////////////////
  59. // FixTB code from August 98 article:
  60. ////////////////////////////////////////////////////////////////
  61.  
  62. public:
  63.     CFlatToolBar();
  64.     virtual ~CFlatToolBar();
  65.  
  66.     static int iVerComCtl32; // version of commctl32.dll (eg 471)
  67.  
  68.     // There is a bug in comctl32.dll, version 4.71+ that causes it to
  69.     // draw vertical separators in addition to horizontal ones, when the
  70.     // toolbar is vertical. Set this to FALSE to eliminate them--but then
  71.     // you lose your dropdown arrows.
  72.     //
  73.     BOOL m_bShowDropdownArrowWhenVertical;
  74.  
  75.     CSize CalcLayout(DWORD nMode, int nLength = -1);
  76.     CSize CalcSize(TBBUTTON* pData, int nCount);
  77.     int WrapToolBar(TBBUTTON* pData, int nCount, int nWidth);
  78.     void SizeToolBar(TBBUTTON* pData, int nCount, int nLength,
  79.         BOOL bVert = FALSE);
  80.  
  81.     // MFC has versions of these are hidden--why?
  82.     //
  83.     void GetButton(int nIndex, TBBUTTON* pButton) const;
  84.     void SetButton(int nIndex, TBBUTTON* pButton);
  85.  
  86. ////////////////////////////////////////////////////////////////
  87. // End FixTb code.
  88. ////////////////////////////////////////////////////////////////
  89.  
  90. public:
  91.     BOOL LoadToolBar(LPCTSTR lpszResourceName);
  92.     BOOL LoadToolBar(UINT nIDResource)
  93.         { return LoadToolBar(MAKEINTRESOURCE(nIDResource)); }
  94.  
  95. // Operations
  96. public:
  97. // Overrides
  98.     // ClassWizard generated virtual function overrides
  99.     //{{AFX_VIRTUAL(CFlatToolBar)
  100.     public:
  101.     virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  102.     virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
  103.     virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
  104.     virtual CSize GetButtonSize(TBBUTTON* pData, int iButton);
  105.     //}}AFX_VIRTUAL
  106.  
  107. // Generated message map functions
  108. protected:
  109.     //{{AFX_MSG(CFlatToolBar)
  110.     afx_msg void OnWindowPosChanging(LPWINDOWPOS lpWndPos);
  111.     afx_msg void OnWindowPosChanged(LPWINDOWPOS lpWndPos);
  112.     afx_msg BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct);
  113.     //}}AFX_MSG
  114.     DECLARE_MESSAGE_MAP()
  115. };
  116.  
  117. ////////////////
  118. // The following class was copied from BARTOOL.CPP in the MFC source.
  119. // All I changed was SetCheck--PD.
  120. //
  121. class CFlatOrCoolBarCmdUI : public CCmdUI // class private to this file !
  122. {
  123. public: // re-implementations only
  124.     virtual void Enable(BOOL bOn);
  125.     virtual void SetCheck(int nCheck);
  126.     virtual void SetText(LPCTSTR lpszText);
  127. };
  128.  
  129. #endif