home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////////
- //
- // File : CoolBar.cpp
- // Project : MsgTrace
- // Component : MsgTracer
- //---------------------------------------------------------------------------
- // Description : a cool-bar
- //
- /////////////////////////////////////////////////////////////////////////////
- //
- // SourceSafe Strings. Do not change.
- //---------------------------------------------------------------------------
- // $Author: jeskes $
- // $Date: $
- // $Revision: $
- //
- /////////////////////////////////////////////////////////////////////////////
-
- #include "StdAfx.h"
- #include "CoolBar.h"
-
- /////////////////////////////////////////////////////////////////////////////
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- ////////////////////////////////////////////////////////////////
- // CCoolbar
- ////////////////////////////////////////////////////////////////
-
- IMPLEMENT_DYNAMIC(CCoolBar, CControlBar)
-
- BEGIN_MESSAGE_MAP(CCoolBar, CControlBar)
- //{{AFX_MSG_MAP(CCoolBar)
- ON_WM_CREATE()
- ON_WM_PAINT()
- ON_WM_ERASEBKGND()
- ON_NOTIFY_REFLECT(RBN_HEIGHTCHANGE, OnHeigtChange)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- ////////////////////////////////////////////////////////////////
- // CCoolbar: construction
- ////////////////////////////////////////////////////////////////
-
- CCoolBar::CCoolBar()
- {
- }
-
- ////////////////////////////////////////////////////////////////
-
- CCoolBar::~CCoolBar()
- {
- }
-
- ////////////////////////////////////////////////////////////////
-
- BOOL CCoolBar::Create(CWnd* pParentWnd, DWORD dwStyle,
- DWORD dwAfxBarStyle, UINT nID)
- {
- ASSERT_VALID(pParentWnd); // must have a parent
-
- // dynamic coolbar not supported
- dwStyle &= ~CBRS_SIZE_DYNAMIC;
-
- // save the style (this code copied from MFC--probably unecessary)
- m_dwStyle = dwAfxBarStyle;
- if (nID == AFX_IDW_TOOLBAR)
- m_dwStyle |= CBRS_HIDE_INPLACE;
-
- // MFC requires these:
- dwStyle |= CCS_NODIVIDER|CCS_NOPARENTALIGN;
-
- // Initialize cool common controls
- static BOOL bInit = FALSE;
- if (!bInit) {
- INITCOMMONCONTROLSEX sex;
- sex.dwSize = sizeof(INITCOMMONCONTROLSEX);
- sex.dwICC = ICC_COOL_CLASSES;
- InitCommonControlsEx(&sex);
- bInit = TRUE;
- }
-
- // Create the cool bar using style and parent.
- CRect rc;
- rc.SetRectEmpty();
- return CWnd::CreateEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL,
- dwStyle, rc, pParentWnd, nID);
- }
-
- ////////////////////////////////////////////////////////////////
-
- int CCoolBar::OnCreate(LPCREATESTRUCT lpcs)
- {
- return CControlBar::OnCreate(lpcs) == -1 ? -1
- : OnCreateBands(); // call pure virtual fn to create bands
- }
-
- ////////////////////////////////////////////////////////////////
- // CCoolbar: message handlers
- ////////////////////////////////////////////////////////////////
-
- void CCoolBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
- {
- UpdateDialogControls(pTarget, bDisableIfNoHndler);
- }
-
- ////////////////////////////////////////////////////////////////
-
- CSize CCoolBar::CalcDynamicLayout(int nLength, DWORD dwMode)
- {
- return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZ);
- }
-
- ////////////////////////////////////////////////////////////////
-
- CSize CCoolBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz)
- {
- CRect rc;
- GetWindowRect(&rc);
- CSize sz(bHorz && bStretch ? 0x7FFF : rc.Width(),
- !bHorz && bStretch ? 0x7FFF : rc.Height());
- return sz;
- }
-
- ////////////////////////////////////////////////////////////////
-
- void CCoolBar::OnHeigtChange(NMHDR* pNMHDR, LRESULT* pRes)
- {
- CRect rc;
- GetWindowRect(&rc);
- OnHeightChange(rc);
- *pRes = 0; // why not?
- }
-
- ////////////////////////////////////////////////////////////////
-
- void CCoolBar::OnHeightChange(const CRect& rcNew)
- {
- CWnd* pParent = GetParent();
- CRect rc;
- pParent->GetWindowRect(&rc);
- pParent->PostMessage(WM_SIZE, 0, MAKELONG(rc.Width(),rc.Height()));
- }
-
- void CCoolBar::OnPaint()
- {
- // bypass CControlBar
- Default();
- }
-
- ////////////////////////////////////////////////////////////////
-
- BOOL CCoolBar::OnEraseBkgnd(CDC* pDC)
- {
- // bypass CControlBar
- return (BOOL)Default();
- }
-
- ////////////////////////////////////////////////////////////////
- // CCoollToolBar
- ////////////////////////////////////////////////////////////////
-
- IMPLEMENT_DYNAMIC(CCoolToolBar, CToolBar)
-
- BEGIN_MESSAGE_MAP(CCoolToolBar, CToolBar)
- ON_WM_NCPAINT()
- ON_WM_PAINT()
- ON_WM_NCCALCSIZE()
- END_MESSAGE_MAP()
-
- ////////////////////////////////////////////////////////////////
- // CCoollToolBar: construction
- ////////////////////////////////////////////////////////////////
-
- CCoolToolBar::CCoolToolBar()
- {
- }
-
- ////////////////////////////////////////////////////////////////
-
- CCoolToolBar::~CCoolToolBar()
- {
- }
-
- ////////////////////////////////////////////////////////////////
-
- void CCoolToolBar::OnNcPaint()
- {
- // bypass CToolBar/CControlBar
- Default();
- }
-
- void CCoolToolBar::OnPaint()
- {
- // bypass CToolBar/CControlBar
- Default();
- }
-
- void CCoolToolBar::OnNcCalcSize(BOOL, NCCALCSIZE_PARAMS*)
- {
- // bypass CToolBar/CControlBar
- Default();
- }
-