- // OAMToolBar.cpp : implementation file
- //
- #include "stdafx.h"
- #include "OAM.h"
- #include "OAMToolBar.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern CBrush m_brBk;
- extern COLORREF _clrText;
- extern HBITMAP hBkBitmap;
- /////////////////////////////////////////////////////////////////////////////
- // COAMToolBar
- IMPLEMENT_DYNAMIC(COAMToolBar, CToolBar)
- COAMToolBar::COAMToolBar()
- {
- }
- COAMToolBar::~COAMToolBar()
- {
- }
- BEGIN_MESSAGE_MAP(COAMToolBar, CToolBar)
- //{{AFX_MSG_MAP(COAMToolBar)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // COAMToolBar message handlers
- void COAMToolBar::OnCustomDraw(NMHDR *pNMHDR, LRESULT *pResult)
- {
- NMTBCUSTOMDRAW *pTVCD = (NMTBCUSTOMDRAW*)pNMHDR;
- CDC* pDC = CDC::FromHandle(pTVCD->nmcd.hdc);
- // The rect for the cell gives correct left and right values.
- CRect rect = pTVCD->nmcd.rc;
- pTVCD->clrText = _clrText;
- pTVCD->hbrLines = m_brBk;
- pTVCD->hbrMonoDither = m_brBk;
- // By default set the return value to do the default behavior.
- *pResult = 0;
- switch( pTVCD->nmcd.dwDrawStage )
- {
- // First stage (for the whole control)
- case CDDS_PREPAINT:
- {
- *pResult = CDRF_NOTIFYITEMDRAW;
- }
- break;
- // Stage three (called for each subitem of the focused item)
- case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
- {
- *pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NOTIFYPOSTPAINT;
- }
- break;
- // Stage four (called for each subitem of the focused item)
- case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM:
- {
- *pResult = CDRF_SKIPDEFAULT;
- }
- break;
- default:
- // Stage two handled here. (called for each item)
- if (pTVCD->nmcd.uItemState & CDIS_HOT)
- {
- // Tell the control that to draw it again.
- *pResult = CDRF_NOTIFYPOSTPAINT;
- }
- if( (pTVCD->nmcd.uItemState & CDIS_FOCUS) || pTVCD->nmcd.uItemState & CDIS_SELECTED)
- {
- *pResult = CDRF_NOTIFYPOSTPAINT;
- }
- if( (pTVCD->nmcd.uItemState & CDIS_CHECKED) )
- {
- *pResult = CDRF_DODEFAULT;
- }
- break;
- }
- CDC::DeleteTempMap( );
- }