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

  1. ////////////////////////////////////////////////////////////////
  2. // CCoolBar 1997 Microsoft Systems Journal. 
  3. // If this program works, it was written by Paul DiLascia.
  4. // If not, I don't know who wrote it.
  5. // Compiles with Visual C++ 5.0 on Windows 95
  6.  
  7. #if !defined(COOLBAR_H_INCLUDED)
  8. #define COOLBAR_H_INCLUDED
  9.  
  10. #if _MSC_VER >= 1000
  11. #pragma once
  12. #endif // _MSC_VER >= 1000
  13.  
  14. //////////////////
  15. // CCoolBar encapsulates IE 4.0 common coolbar for MFC.
  16. //
  17. class CLASS_EXPORT CCoolBar : public CControlBar {
  18. protected:
  19.     DECLARE_DYNAMIC(CCoolBar)
  20.  
  21. public:
  22.     CCoolBar();
  23.     virtual ~CCoolBar();
  24.  
  25.     BOOL Create(CWnd* pParentWnd, DWORD dwStyle,
  26.         DWORD dwAfxBarStyle = CBRS_ALIGN_TOP,
  27.         UINT nID = AFX_IDW_TOOLBAR);
  28.  
  29.     // Message wrappers
  30.     BOOL GetBarInfo(LPREBARINFO lp)
  31.         { ASSERT(::IsWindow(m_hWnd));
  32.           return (BOOL)SendMessage(RB_GETBARINFO, 0, (LPARAM)lp); }
  33.     BOOL SetBarInfo(LPREBARINFO lp)
  34.         { ASSERT(::IsWindow(m_hWnd));
  35.           return (BOOL)SendMessage(RB_SETBARINFO, 0, (LPARAM)lp); }
  36.     BOOL GetBandInfo(int iBand, LPREBARBANDINFO lp)
  37.         { ASSERT(::IsWindow(m_hWnd));
  38.           return (BOOL)SendMessage(RB_GETBANDINFO, iBand, (LPARAM)lp); }
  39.     BOOL SetBandInfo(int iBand, LPREBARBANDINFO lp)
  40.         { ASSERT(::IsWindow(m_hWnd));
  41.           return (BOOL)SendMessage(RB_SETBANDINFO, iBand, (LPARAM)lp); }
  42.     BOOL InsertBand(int iWhere, LPREBARBANDINFO lp)
  43.         { ASSERT(::IsWindow(m_hWnd));
  44.           return (BOOL)SendMessage(RB_INSERTBAND, (WPARAM)iWhere, (LPARAM)lp); }
  45.     BOOL DeleteBand(int nWhich)
  46.         { ASSERT(::IsWindow(m_hWnd));
  47.           return (BOOL)SendMessage(RB_INSERTBAND, (WPARAM)nWhich); }
  48.     int GetBandCount()
  49.         { ASSERT(::IsWindow(m_hWnd));
  50.           return (int)SendMessage(RB_GETBANDCOUNT); }
  51.     int GetRowCount()
  52.         { ASSERT(::IsWindow(m_hWnd));
  53.          return (int)SendMessage(RB_GETROWCOUNT); }
  54.     int GetRowHeight(int nWhich)
  55.         { ASSERT(::IsWindow(m_hWnd));
  56.          return (int)SendMessage(RB_GETROWHEIGHT, (WPARAM)nWhich); }
  57.  
  58. // Overrides
  59.     // ClassWizard generated virtual function overrides
  60.     //{{AFX_VIRTUAL(CCoolBar)
  61.     protected:
  62.     // new virtual functions you must/can override
  63.     virtual BOOL OnCreateBands() = 0; // return -1 if failed
  64.     virtual void OnHeightChange(const CRect& rcNew);
  65.     // CControlBar Overrides
  66.     virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
  67.     virtual CSize CalcDynamicLayout(int nLength, DWORD nMode);
  68.     virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
  69.     //}}AFX_VIRTUAL
  70.  
  71.     // Generated message map functions
  72. protected:
  73.     //{{AFX_MSG(CCoolBar)
  74.     afx_msg int  OnCreate(LPCREATESTRUCT lpcs);
  75.     afx_msg void OnPaint();
  76.     afx_msg void OnHeigtChange(NMHDR* pNMHDR, LRESULT* pRes);
  77.     afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  78.     //}}AFX_MSG
  79.     DECLARE_MESSAGE_MAP()
  80. };
  81.  
  82. //////////////////
  83. // Programmer-friendly REBARBANDINFO initializes itself
  84. //
  85. class CLASS_EXPORT CRebarBandInfo : public REBARBANDINFO {
  86. public:
  87.     CRebarBandInfo() {
  88.         memset(this, 0, sizeof(REBARBANDINFO));
  89.         cbSize = sizeof(REBARBANDINFO);
  90.  
  91.         // *** Kirk Stowell
  92.         fMask   = RBBIM_STYLE|RBBIM_CHILD|RBBIM_CHILDSIZE|RBBIM_BACKGROUND|RBBIM_COLORS;
  93.         fStyle  = RBBS_FIXEDBMP;
  94.         clrFore = GetSysColor(COLOR_BTNTEXT);
  95.         clrBack    = GetSysColor(COLOR_BTNFACE);
  96.     }
  97. };
  98.  
  99. #endif