home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / MSGTRACE.ZIP / MyProjects / MsgTrace / MsgTracer / CoolBar.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-05-30  |  5.1 KB  |  208 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File        : CoolBar.cpp
  4. // Project     : MsgTrace
  5. // Component   : MsgTracer
  6. //---------------------------------------------------------------------------
  7. // Description : a cool-bar
  8. //
  9. /////////////////////////////////////////////////////////////////////////////
  10. //
  11. // SourceSafe Strings. Do not change.
  12. //---------------------------------------------------------------------------
  13. // $Author: jeskes $
  14. // $Date: $
  15. // $Revision: $
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18.  
  19. #include "StdAfx.h"
  20. #include "CoolBar.h"
  21.  
  22. /////////////////////////////////////////////////////////////////////////////
  23.  
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29.  
  30. ////////////////////////////////////////////////////////////////
  31. // CCoolbar
  32. ////////////////////////////////////////////////////////////////
  33.  
  34. IMPLEMENT_DYNAMIC(CCoolBar, CControlBar)
  35.  
  36. BEGIN_MESSAGE_MAP(CCoolBar, CControlBar)
  37.     //{{AFX_MSG_MAP(CCoolBar)
  38.     ON_WM_CREATE()
  39.     ON_WM_PAINT()
  40.     ON_WM_ERASEBKGND()
  41.     ON_NOTIFY_REFLECT(RBN_HEIGHTCHANGE, OnHeigtChange)
  42.     //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44.  
  45. ////////////////////////////////////////////////////////////////
  46. // CCoolbar: construction
  47. ////////////////////////////////////////////////////////////////
  48.  
  49. CCoolBar::CCoolBar()
  50. {
  51. }
  52.  
  53. ////////////////////////////////////////////////////////////////
  54.  
  55. CCoolBar::~CCoolBar()
  56. {
  57. }
  58.  
  59. ////////////////////////////////////////////////////////////////
  60.  
  61. BOOL CCoolBar::Create(CWnd* pParentWnd, DWORD dwStyle,
  62.     DWORD dwAfxBarStyle, UINT nID)
  63. {
  64.     ASSERT_VALID(pParentWnd);   // must have a parent
  65.  
  66.     // dynamic coolbar not supported
  67.     dwStyle &= ~CBRS_SIZE_DYNAMIC;
  68.  
  69.     // save the style (this code copied from MFC--probably unecessary)
  70.     m_dwStyle = dwAfxBarStyle;
  71.     if (nID == AFX_IDW_TOOLBAR)
  72.         m_dwStyle |= CBRS_HIDE_INPLACE;
  73.  
  74.     // MFC requires these:
  75.     dwStyle |= CCS_NODIVIDER|CCS_NOPARENTALIGN;
  76.  
  77.     // Initialize cool common controls
  78.     static BOOL bInit = FALSE;
  79.     if (!bInit) {
  80.         INITCOMMONCONTROLSEX sex;
  81.         sex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  82.         sex.dwICC = ICC_COOL_CLASSES;
  83.         InitCommonControlsEx(&sex);
  84.         bInit = TRUE;
  85.     }
  86.  
  87.     // Create the cool bar using style and parent.
  88.     CRect rc;
  89.     rc.SetRectEmpty();
  90.     return CWnd::CreateEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL,
  91.         dwStyle, rc, pParentWnd, nID);
  92. }
  93.  
  94. ////////////////////////////////////////////////////////////////
  95.  
  96. int CCoolBar::OnCreate(LPCREATESTRUCT lpcs)
  97. {
  98.     return CControlBar::OnCreate(lpcs) == -1 ? -1
  99.         : OnCreateBands();    // call pure virtual fn to create bands
  100. }
  101.  
  102. ////////////////////////////////////////////////////////////////
  103. // CCoolbar: message handlers
  104. ////////////////////////////////////////////////////////////////
  105.  
  106. void CCoolBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
  107. {
  108.     UpdateDialogControls(pTarget, bDisableIfNoHndler);
  109. }
  110.  
  111. ////////////////////////////////////////////////////////////////
  112.  
  113. CSize CCoolBar::CalcDynamicLayout(int nLength, DWORD dwMode)
  114. {
  115.     return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZ);
  116. }
  117.  
  118. ////////////////////////////////////////////////////////////////
  119.  
  120. CSize CCoolBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
  121. {
  122.     CRect rc;
  123.     GetWindowRect(&rc);
  124.     CSize sz(bHorz && bStretch ? 0x7FFF : rc.Width(),
  125.         !bHorz && bStretch ? 0x7FFF : rc.Height());
  126.     return sz;
  127. }
  128.  
  129. ////////////////////////////////////////////////////////////////
  130.  
  131. void CCoolBar::OnHeigtChange(NMHDR* pNMHDR, LRESULT* pRes)
  132. {
  133.     CRect rc;
  134.     GetWindowRect(&rc);
  135.     OnHeightChange(rc);
  136.     *pRes = 0; // why not?
  137. }
  138.  
  139. ////////////////////////////////////////////////////////////////
  140.  
  141. void CCoolBar::OnHeightChange(const CRect& rcNew)
  142. {
  143.     CWnd* pParent = GetParent();
  144.     CRect rc;
  145.     pParent->GetWindowRect(&rc);
  146.     pParent->PostMessage(WM_SIZE, 0, MAKELONG(rc.Width(),rc.Height()));
  147. }
  148.  
  149. void CCoolBar::OnPaint()
  150. {
  151.     // bypass CControlBar
  152.     Default();    
  153. }
  154.  
  155. ////////////////////////////////////////////////////////////////
  156.  
  157. BOOL CCoolBar::OnEraseBkgnd(CDC* pDC)
  158. {
  159.     // bypass CControlBar
  160.     return (BOOL)Default();  
  161. }
  162.  
  163. ////////////////////////////////////////////////////////////////
  164. // CCoollToolBar
  165. ////////////////////////////////////////////////////////////////
  166.  
  167. IMPLEMENT_DYNAMIC(CCoolToolBar, CToolBar)
  168.  
  169. BEGIN_MESSAGE_MAP(CCoolToolBar, CToolBar)
  170.     ON_WM_NCPAINT()
  171.     ON_WM_PAINT()
  172.     ON_WM_NCCALCSIZE()
  173. END_MESSAGE_MAP()
  174.  
  175. ////////////////////////////////////////////////////////////////
  176. // CCoollToolBar: construction
  177. ////////////////////////////////////////////////////////////////
  178.  
  179. CCoolToolBar::CCoolToolBar()
  180. {
  181. }
  182.  
  183. ////////////////////////////////////////////////////////////////
  184.  
  185. CCoolToolBar::~CCoolToolBar()
  186. {
  187. }
  188.  
  189. ////////////////////////////////////////////////////////////////
  190.  
  191. void CCoolToolBar::OnNcPaint()
  192. {
  193.     // bypass CToolBar/CControlBar
  194.     Default();    
  195. }
  196.  
  197. void CCoolToolBar::OnPaint()
  198. {
  199.     // bypass CToolBar/CControlBar
  200.     Default();    
  201. }
  202.  
  203. void CCoolToolBar::OnNcCalcSize(BOOL, NCCALCSIZE_PARAMS*)
  204. {
  205.     // bypass CToolBar/CControlBar
  206.     Default();    
  207. }
  208.