void CColourPicker::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
    ASSERT(lpDrawItemStruct);
    
    CDC*    pDC     = CDC::FromHandle(lpDrawItemStruct->hDC);
    CRect   rect    = lpDrawItemStruct->rcItem;
    UINT    state   = lpDrawItemStruct->itemState;
    CString m_strText;

    CSize Margins(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE));

    // Draw arrow
    if (m_bActive) state |= ODS_SELECTED;
    pDC->DrawFrameControl(&m_ArrowRect, DFC_SCROLL, DFCS_SCROLLDOWN  | 
                          ((state & ODS_SELECTED) ? DFCS_PUSHED : 0) |
                          ((state & ODS_DISABLED) ? DFCS_INACTIVE : 0));

    pDC->DrawEdge(rect, EDGE_SUNKEN, BF_RECT);

    // Must reduce the size of the "client" area of the button due to edge thickness.
    rect.DeflateRect(Margins.cx, Margins.cy);

    // Fill remaining area with colour
    rect.right -= m_ArrowRect.Width();

    CBrush brush( ((state & ODS_DISABLED) || m_crColourBk == CLR_DEFAULT)? 
                  ::GetSysColor(COLOR_3DFACE) : m_crColourBk);
    CBrush* pOldBrush = (CBrush*) pDC->SelectObject(&brush);
	pDC->SelectStockObject(NULL_PEN);
    pDC->Rectangle(rect);
    pDC->SelectObject(pOldBrush);

    // Draw the window text (if any)
    GetWindowText(m_strText);
    if (m_strText.GetLength())
    {
        pDC->SetBkMode(TRANSPARENT);
        if (state & ODS_DISABLED)
        {
            rect.OffsetRect(1,1);
            pDC->SetTextColor(::GetSysColor(COLOR_3DHILIGHT));
            pDC->DrawText(m_strText, rect, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
            rect.OffsetRect(-1,-1);
            pDC->SetTextColor(::GetSysColor(COLOR_3DSHADOW));
            pDC->DrawText(m_strText, rect, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
        }
        else
        {
            pDC->SetTextColor((m_crColourText == CLR_DEFAULT)? 0 : m_crColourText);
            pDC->DrawText(m_strText, rect, DT_CENTER|DT_SINGLELINE|DT_VCENTER);
        }
    }

    // Draw focus rect
    if (state & ODS_FOCUS) 
    {
        rect.DeflateRect(1,1);
        pDC->DrawFocusRect(rect);
    }
}
Example #2
0
void WindowSelector::OnNcPaint()
{
    CWnd::OnNcPaint();

    CRect rc;
    GetWindowRect(rc);

    rc.right = rc.Width() - (::GetSystemMetrics(SM_CXSMSIZE) + ::GetSystemMetrics(SM_CXFRAME) + ::GetSystemMetrics(SM_CXBORDER));
    rc.right -= 4;
    rc.left =  rc.right - ::GetSystemMetrics(SM_CXSMSIZE) - 6;

    rc.top = ::GetSystemMetrics(SM_CYFRAME);
    rc.bottom = rc.top + ::GetSystemMetrics(SM_CYSMSIZE);
    CDC* pDC = GetWindowDC();

    CDC dcMem;
    dcMem.CreateCompatibleDC(pDC);
    CBitmap bitmap;
    bitmap.CreateCompatibleBitmap(pDC, rc.Width(), rc.Height());
    CBitmap* pOldBitmap = dcMem.SelectObject(&bitmap);

    CRect rect(0, 0, rc.Width(), rc.Height());
    if (m_bButtonPinned) {
        dcMem.DrawFrameControl(rect, DFC_BUTTON, DFCS_BUTTONPUSH|DFCS_CHECKED);
        dcMem.DrawState(CPoint(1, 1), CSize(rect.Width()-2, rect.Height()-2),
                        &m_bmpPinned, DST_BITMAP);
    } else {
        dcMem.DrawFrameControl(rect, DFC_BUTTON, DFCS_BUTTONPUSH);
        dcMem.DrawState(CPoint(1, 1), CSize(rect.Width()-2, rect.Height()-2),
                        &m_bmpUnpinned, DST_BITMAP);
    }

    pDC->BitBlt(rc.left, rc.top, rc.Width(), rc.Height(),
                &dcMem, 0, 0, SRCCOPY);

    dcMem.SelectObject(pOldBitmap);
    ReleaseDC(&dcMem);
    ReleaseDC(pDC);

    m_rcButton = rc;
}
Example #3
0
// CMyButton message handlers
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CDC* pDC   = CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect rect = lpDrawItemStruct->rcItem;
	UINT state = lpDrawItemStruct->itemState;

	CString strText;
	GetWindowText(strText);

	// draw the control edges (DrawFrameControl is handy!)

	if (state & ODS_SELECTED)
		pDC->DrawFrameControl(rect, DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_PUSHED);
	else
		pDC->DrawFrameControl(rect, DFC_BUTTON, DFCS_BUTTONPUSH);

	// Deflate the drawing rect by the size of the button's edges

	rect.DeflateRect( CSize(GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE)));

	// Draw the text
	if (!strText.IsEmpty())
	{
		CSize Extent = pDC->GetTextExtent(strText);
		CPoint pt( rect.CenterPoint().x - Extent.cx/2, 
			rect.CenterPoint().y - Extent.cy/2 );

		if (state & ODS_SELECTED) 
			pt.Offset(1,1);

		int nMode = pDC->SetBkMode(TRANSPARENT);

		if (state & ODS_DISABLED)
			pDC->DrawState(pt, Extent, strText, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL);
		else
			pDC->TextOut(pt.x, pt.y, strText);

		pDC->SetBkMode(nMode);
	}
}
void CColorSelector::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    // TODO: Add your message handler code here and/or call default
    CDC omDc;
    omDc.Attach(lpDrawItemStruct->hDC);
	UINT unButtonState  = lpDrawItemStruct->itemState;
	int nPushState = ((unButtonState & ODS_SELECTED) ? DFCS_PUSHED : 0) |
					 ((unButtonState & ODS_DISABLED) ? DFCS_INACTIVE : 0);

    CRect omItemRect    = lpDrawItemStruct->rcItem;
    
	
    
	CRect omArrowRect;
    omArrowRect.left = max(0, omItemRect.Width()- GetSystemMetrics(SM_CXHTHUMB) - 3 );
    omArrowRect.right = max(0, omItemRect.Width()-3);
    omArrowRect.top = 3;
    omArrowRect.bottom = max(omItemRect.Height()-3, GetSystemMetrics(SM_CYVTHUMB)-3);
    
	
    omDc.DrawFrameControl(&omArrowRect, DFC_SCROLL, DFCS_SCROLLDOWN  | nPushState);

    // Create backgroung brush
    CBrush brush( m_omColorBkg);
    omDc.SelectStockObject(BLACK_PEN);
    omDc.DrawEdge(&lpDrawItemStruct->rcItem, EDGE_RAISED, BF_RECT);
    CRect omButtonRect;
    
    omButtonRect.left = lpDrawItemStruct->rcItem.left+5;
    omButtonRect.top = lpDrawItemStruct->rcItem.top+5;
    omButtonRect.right = lpDrawItemStruct->rcItem.right - omArrowRect.Width()-5;// - omArrowRect.Width() ;
    omButtonRect.bottom = lpDrawItemStruct->rcItem.bottom - 5;
    
    //omButtonRect.DeflateRect(3, 3);
    omDc.FillRect(omButtonRect, &brush);
    // Select Old Brush
    omDc.SelectObject(brush);
    
    omButtonRect.DeflateRect(-1, -1);
    
    omDc.Rectangle(omButtonRect);

    if (unButtonState & ODS_FOCUS) 
    {
        omButtonRect.DeflateRect(1,1);
        omDc.DrawFocusRect(omButtonRect);
    }
}
template <class BASE> void CDialogMinTrayBtn<BASE>::MinTrayBtnDraw()
{
	if (!MinTrayBtnIsVisible())
		return;

	CDC	*pDC = GetWindowDC();

	if (pDC == NULL)
		return;

	CRect	rcBtn = MinTrayBtnGetRect();
	UINT	uiState;

	if (IsWindowsClassicStyle())
	{
	//	Button
		uiState = DFCS_BUTTONPUSH;

		if (!m_bMinTrayBtnUp)
			uiState |= DFCS_PUSHED;

		pDC->DrawFrameControl(rcBtn, DFC_BUTTON, uiState);

	//	Dot
		rcBtn.DeflateRect(2,2);

		UINT	iCptWdth = MinTrayBtnGetSize().cy + (CAPTION_BUTTONSPACE << 1);
		UINT	iPixRatio1 = iCptWdth >= 20 ? 2 + ((iCptWdth - 20) >> 3) : (iCptWdth >= 14 ? 2 : 1);
		UINT	iPixRatio2 = iCptWdth >= 12 ? 1 + ((iCptWdth - 12) >> 3) : 0;
		CRect	rcDot(CPoint(0, 0), CPoint((1 + iPixRatio1 * 3) >> 1, iPixRatio1));
		CSize	szSpc((1 + iPixRatio2 * 3) >> 1, iPixRatio2);

		rcDot += rcBtn.BottomRight() - rcDot.Size() - szSpc;

		if (!m_bMinTrayBtnUp)
			rcDot += CPoint(1, 1);

		int	iColor = COLOR_BTNTEXT;

		if (!m_bMinTrayBtnEnabled)
		{
			iColor = COLOR_GRAYTEXT;
			pDC->FillSolidRect(rcDot + CPoint(1, 1), GetSysColor(COLOR_BTNHILIGHT));
		}
		pDC->FillSolidRect(rcDot, GetSysColor(iColor));
	}
	else
	{
Example #6
0
void ColourButton::OnCustomDraw(NMHDR* nmhdr, LRESULT* result)
{
  NMCUSTOMDRAW* nmcd = (NMCUSTOMDRAW*)nmhdr;
  *result = CDRF_DODEFAULT;

  switch (nmcd->dwDrawStage)
  {
  case CDDS_PREPAINT:
    {
      CDC* dc = CDC::FromHandle(nmcd->hdc);
      CRect r(nmcd->rc);

      bool selected = ((nmcd->uItemState & CDIS_SELECTED) != 0);
      bool disabled = ((nmcd->uItemState & CDIS_DISABLED) != 0);
      bool focus = ((nmcd->uItemState & CDIS_FOCUS) != 0);
      if (SendMessage(WM_QUERYUISTATE) & UISF_HIDEFOCUS)
        focus = false;

      if (IsAppThemed())
      {
        HTHEME theme = OpenThemeData(this,L"Button");
        if (theme)
        {
          // Get the area to draw into
          GetThemeBackgroundContentRect(theme,dc,BP_PUSHBUTTON,PBS_NORMAL,r);
          CloseThemeData(theme);
        }
      }
      else
      {
        UINT state = DFCS_BUTTONPUSH|DFCS_ADJUSTRECT;
        if (disabled)
          state |= DFCS_INACTIVE;
        if (selected)
          state |= DFCS_PUSHED;
        dc->DrawFrameControl(r,DFC_BUTTON,state);

        if (selected)
          r.OffsetRect(1,1);
      }

      DrawControl(dc,r,disabled,focus);
      *result = CDRF_SKIPDEFAULT;
    }
    break;
  }
}
Example #7
0
void ColourButton::DrawItem(LPDRAWITEMSTRUCT dis)
{
  bool selected = ((dis->itemState & ODS_SELECTED) != 0);
  bool disabled = ((dis->itemState & ODS_DISABLED) != 0);
  bool focus = ((dis->itemState & ODS_FOCUS) != 0) && ((dis->itemState & ODS_NOFOCUSRECT) == 0);
  CDC* dc = CDC::FromHandle(dis->hDC);
  CRect r(dis->rcItem);

  UINT state = DFCS_BUTTONPUSH|DFCS_ADJUSTRECT;
  if (disabled)
    state |= DFCS_INACTIVE;
  if (selected)
    state |= DFCS_PUSHED;
  dc->DrawFrameControl(r,DFC_BUTTON,state);

  if (selected)
    r.OffsetRect(1,1);
  DrawControl(dc,r,disabled,focus);
}
void CXTPCustomizeToolbarsPageCheckListBox::PreDrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	DRAWITEMSTRUCT drawItem;
	memcpy(&drawItem, lpDrawItemStruct, sizeof(DRAWITEMSTRUCT));

	if ((((LONG)drawItem.itemID) >= 0) &&
		((drawItem.itemAction & (ODA_DRAWENTIRE | ODA_SELECT)) != 0))
	{
		int cyItem = GetItemHeight(drawItem.itemID);

		CDC* pDC = CDC::FromHandle(drawItem.hDC);

		int nCheck = GetCheck(drawItem.itemID);

		CRect rectCheck = drawItem.rcItem;
		rectCheck.left += 1;
		rectCheck.top += 1 + max(0, (cyItem - m_sizeCheck.cy) / 2);
		rectCheck.right = rectCheck.left + m_sizeCheck.cx;
		rectCheck.bottom = rectCheck.top + m_sizeCheck.cy;

		CRect rectItem = drawItem.rcItem;
		rectItem.right = rectItem.left + m_sizeCheck.cx + 2;
		CRect rectCheckBox = OnGetCheckPosition(rectItem, rectCheck);

		if (m_themeHelper.IsAppThemeReady())
		{
			m_themeHelper.DrawThemeBackground(pDC->m_hDC, BP_CHECKBOX,
				nCheck ? CBS_CHECKEDNORMAL : CBS_UNCHECKEDNORMAL, &rectCheckBox, NULL);
		}
		else
		{
			ASSERT(rectCheck.IntersectRect(rectItem, rectCheckBox));
			ASSERT((rectCheck == rectCheckBox) && (rectCheckBox.Size() == m_sizeCheck));

			pDC->DrawFrameControl(rectCheckBox, DFC_BUTTON, DFCS_BUTTONCHECK | (nCheck ? DFCS_CHECKED : 0));
		}
	}

	drawItem.rcItem.left = drawItem.rcItem.left + m_sizeCheck.cx + 3;

	DrawItem(&drawItem);
}
Example #9
0
void CBmpButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	if(m_bitmap.GetObject==NULL)
		return;

	UINT    nOffset=0; 
	UINT	nFrameStyle=0;
	BOOL	bDRAWFOCUSONLY = FALSE;
	int nState=lpDrawItemStruct->itemState;		
	UINT	nNewAction = lpDrawItemStruct->itemAction;
	
	if ( nState & ODS_SELECTED)
	{
		nFrameStyle = DFCS_PUSHED;
		nOffset += 1;
	}
	nState=DSS_NORMAL;
	if (nNewAction == ODA_FOCUS )
		bDRAWFOCUSONLY = TRUE;
	
	CRect rt;
	GetClientRect(&rt);
	if(!bDRAWFOCUSONLY)
	{
		CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
		CRect rtControl( lpDrawItemStruct->rcItem );
		CPoint pt(rtControl.left,rtControl.top);
		CSize sizeDraw;		
		sizeDraw.cx=rt.Width();
		sizeDraw.cy=rt.Height();			
		pt.Offset(nOffset,nOffset);
		pDC->Rectangle( &lpDrawItemStruct->rcItem );		
		pDC->DrawFrameControl(&rtControl, DFC_BUTTON, DFCS_BUTTONPUSH | nFrameStyle);	
		pDC->DrawState(pt,sizeDraw,m_bitmap,DST_BITMAP|nState);	
	}
}
Example #10
0
void CDropListBox::DrawItem(LPDRAWITEMSTRUCT pDIStruct) 
{
	//
	// Set var's
	BOOL			bIsSelected = FALSE;
	BOOL			bIsDisabled = FALSE;
	BOOL			bIsChecked = FALSE;
	COLORREF		clrNormal = ::GetSysColor(COLOR_WINDOW);
	COLORREF		clrSelected = ::GetSysColor(COLOR_HIGHLIGHT);
	COLORREF		clrText = ::GetSysColor(COLOR_WINDOWTEXT);
	COLORREF		clrTextHilight = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
	COLORREF		clrTextDisabled = ::GetSysColor(COLOR_GRAYTEXT);

	CDC* pDC = CDC::FromHandle(pDIStruct->hDC);
	PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(pDIStruct->itemID);

	bIsDisabled = (pItem->state & ACBIS_DISABLED);
	bIsChecked = (pItem->state & ACBIS_CHECKED);
	if( /*(pDIStruct->itemAction | ODA_SELECT) &&*/ (pDIStruct->itemState & ODS_SELECTED) )
		bIsSelected = TRUE;

	CRect rcItem = pDIStruct->rcItem;
	CRect rcText = pDIStruct->rcItem;
	CRect rcCheck = pDIStruct->rcItem;

	int nSavedDC = pDC->SaveDC();

	pDC->SetBkMode(TRANSPARENT);
	if( m_pComboParent->GetACBStyle() & ACBS_CHECKED )
	{
		if( bIsChecked )
		{
			rcCheck.right = rcCheck.left + rcCheck.Height();
			pDC->DrawFrameControl( &rcCheck, DFC_MENU, DFCS_MENUCHECK );
		}
		rcText.left += rcItem.Height()-4;
		rcItem.left += rcItem.Height()-4;
	}

	//disabled
	if(bIsDisabled)
	{
		pDC->FillSolidRect( rcItem, clrNormal);

		pDC->SetTextColor(clrTextDisabled);
	}
	//selected
	else if(bIsSelected)
	{
		pDC->FillSolidRect( rcItem, clrSelected);

		pDC->SetTextColor( clrTextHilight );
	}
	//normal
	else
	{
		if(pItem->GetChildCount() > 0)
		{
			CRect rcTemp = rcItem;
			rcTemp.bottom -= 1;
			pDC->FillSolidRect(rcTemp, RGB(245, 245, 245));

			rcTemp = rcItem;
			rcTemp.top = rcTemp.bottom - 1;
			pDC->FillSolidRect(rcTemp, RGB(200, 216, 255));
		}
		else
		{
			pDC->FillSolidRect( rcItem, clrNormal);
		}

		pDC->SetTextColor(clrText);
	}

	int nWidth = DrawStateImage(rcText, pDC, pItem, m_nSpaceX);
	rcText.left += nWidth;

	nWidth = DrawItemImage(rcText, pDC, pItem, m_nSpaceX);
	rcText.left += nWidth;

	//Draw Text
	rcText.left += 2;
	pDC->DrawText( pItem->strText, &rcText, DT_SINGLELINE|DT_VCENTER);

	//restore dc
	pDC->RestoreDC(nSavedDC);
}
Example #11
0
void CCoolDialogBar::DrawGripper(CDC & dc)
{
    // no gripper if floating
	if( m_dwStyle & CBRS_FLOATING )
		return;

	// -==HACK==-
	// in order to calculate the client area properly after docking,
	// the client area must be recalculated twice (I have no idea why)
	m_pDockSite->RecalcLayout();
	// -==END HACK==-

	CRect gripper;
	GetWindowRect( gripper );
	ScreenToClient( gripper );
	gripper.OffsetRect( -gripper.left, -gripper.top );
	
	if( m_dwStyle & CBRS_ORIENT_HORZ ) {
		
		// gripper at left
		m_rectGripper.top		= gripper.top + 40;
		m_rectGripper.bottom	= gripper.bottom;
		m_rectGripper.left		= gripper.left;
		m_rectGripper.right	= gripper.left + 20;

		// draw close box
		m_rectClose.left = gripper.left + 7;
		m_rectClose.right = m_rectClose.left + 12;
		m_rectClose.top = gripper.top + 10;
		m_rectClose.bottom = m_rectClose.top + 12;
		dc.DrawFrameControl(m_rectClose, DFC_CAPTION, DFCS_CAPTIONCLOSE);

		// draw docking toggle box
		m_rectUndock = m_rectClose;
		m_rectUndock.OffsetRect(0,13);
		dc.DrawFrameControl(m_rectUndock, DFC_CAPTION, DFCS_CAPTIONMAX);

		gripper.top += 38;
		gripper.bottom -= 10;
		gripper.left += 10;
		gripper.right = gripper.left+3;
        dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow );
		
		gripper.OffsetRect(4, 0);
        dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow );
	}
	
	else {
		
		// gripper at top
		m_rectGripper.top		= gripper.top;
		m_rectGripper.bottom	= gripper.top + 20;
		m_rectGripper.left		= gripper.left;
		m_rectGripper.right		= gripper.right - 40;

		// draw close box
		m_rectClose.right = gripper.right - 10;
		m_rectClose.left = m_rectClose.right - 11;
		m_rectClose.top = gripper.top + 7;
		m_rectClose.bottom = m_rectClose.top + 11;
		dc.DrawFrameControl(m_rectClose, DFC_CAPTION, DFCS_CAPTIONCLOSE);


		// draw docking toggle box
		m_rectUndock = m_rectClose;
		m_rectUndock.OffsetRect(-13,0);
		dc.DrawFrameControl(m_rectUndock, DFC_CAPTION, DFCS_CAPTIONMAX);

		gripper.right -= 38;
		gripper.left += 10;
		gripper.top += 10;
		gripper.bottom = gripper.top+3;
		dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow );
		
		gripper.OffsetRect(0, 4);
        dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow );
	}

}
Example #12
0
void COFSNcDlg::DrawCaption(CDC &dc,const CRect &m_Rect)
{
	if(m_Rect.Width()==0||m_Rect.Height()==0) return;
	switch(m_CaptionMode)
	{
     case CAP_NONE:
	 case CAP_COLOR:	 
		 {
			 CFont m_font;
			 CBrush m_br;
			 CRect m_TextRect = m_Rect;
			 
			 if(m_bActive)
				 m_br.CreateSolidBrush(m_ActiveColor);
		     else
			     m_br.CreateSolidBrush(m_InactiveColor);

			 dc.FillRect(m_Rect,&m_br);
			 CString str;
			 GetWindowText(str);
			 m_font.Attach(GetStockObject(DEFAULT_GUI_FONT));
			 dc.SelectObject(&m_font);
			 dc.SetTextColor(RGB(255,255,255));
			 dc.SetBkMode(TRANSPARENT);
			 m_TextRect.right -= 80;
			 dc.DrawText(str,(LPRECT)&m_TextRect ,DT_LEFT|DT_VCENTER|DT_END_ELLIPSIS|DT_SINGLELINE);
		 }
		 break;
     case CAP_BITMAP_1:	 		
		 {
			 CDC dcT;
			 dcT.CreateCompatibleDC(&dc);
			 dcT.SelectObject(pActiveBMP);
			 dc.BitBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,SRCCOPY);
		 }
		 break;
     case CAP_BITMAP_1_ZOOM:	 		 
		 {
			 CDC dcT;
			 dcT.CreateCompatibleDC(&dc);
			 dcT.SelectObject(pActiveBMP);
			 dc.StretchBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,m_ActiveBMPSize.cx,m_ActiveBMPSize.cy,SRCCOPY);
//			 dc.BitBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,SRCCOPY);
		 }
		 break;
     case CAP_BITMAP_2:	 		 
		 {
			 CDC dcT;
			 dcT.CreateCompatibleDC(&dc);
			 if(m_bActive)
				 dcT.SelectObject(pActiveBMP);
			 else
                 dcT.SelectObject(pInactiveBMP);    
			 dc.BitBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,SRCCOPY);
		 }
		 break;
     case CAP_BITMAP_2_ZOOM:	 		 
		 {
			 CDC dcT;
			 dcT.CreateCompatibleDC(&dc);
			 if(m_bActive)
			 {
				 dcT.SelectObject(pActiveBMP);
				 dc.StretchBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,m_ActiveBMPSize.cx,m_ActiveBMPSize.cy,SRCCOPY);
			 }
			 else
			 {
                 dcT.SelectObject(pInactiveBMP);    
				 dc.StretchBlt(m_Rect.left,m_Rect.top,m_Rect.Width(),m_Rect.Height(),&dcT,0,0,m_InactiveBMPSize.cx,m_InactiveBMPSize.cy,SRCCOPY);
			 }
		 }
		 break;
	}

	DWORD dwStyle = GetStyle();
	CRect m_ButtonRect;
	m_ButtonRect.SetRect(m_Rect.right - CaptionH +2 ,m_Rect.top + 4,
		m_Rect.right - 2,m_Rect.bottom - 2);
	
	if(dwStyle&WS_SYSMENU)
		dc.DrawFrameControl(&m_ButtonRect,DFC_CAPTION,DFCS_CAPTIONCLOSE);
	
	if (dwStyle & WS_MAXIMIZEBOX) 
	{
	   m_ButtonRect-=CPoint(CaptionH-2,0);
       dc.DrawFrameControl(&m_ButtonRect, DFC_CAPTION, IsZoomed()?DFCS_CAPTIONRESTORE:DFCS_CAPTIONMAX);
	}
	
	if (dwStyle & WS_MINIMIZEBOX) 
	{
		m_ButtonRect-=CPoint(CaptionH-2,0);
        dc.DrawFrameControl(&m_ButtonRect, DFC_CAPTION ,DFCS_CAPTIONMIN);
	}

}
Example #13
0
////////////////////////////////////////////////////////////////////////////////
//
// FUNCTION:	  DrawItem
//
// DESCRIPTION:	Called in response to draw the button
//
// NOTES:
//
// MAINTENANCE:
// Name:		  Date:	  Version:	Notes:
// NT ALMOND	210100	1.0			  Origin
//
////////////////////////////////////////////////////////////////////////////////
void CCoolBtn::DrawItem(DRAWITEMSTRUCT* lpDIS)
{
    if (lpDIS->CtlType != ODT_BUTTON)
        return;

    CFont *pFont = CFont::FromHandle((HFONT)GetStockObject(DEFAULT_GUI_FONT));

    CDC dcMem;
    CBitmap bmp;

    CRect btnRect(lpDIS->rcItem);
    CRect trueRect(btnRect);

    CDC *pDC = CDC::FromHandle(lpDIS->hDC);

    ////////////////////////////////////////
    // Button Background                  //
    ////////////////////////////////////////

    pDC->FillRect(trueRect,&CBrush(GetSysColor(COLOR_BTNFACE)));

    BOOL bDisabled = ODS_DISABLED & lpDIS->itemState;

    if (m_bDefaultBtn)
        btnRect.DeflateRect(1,1);

    CRect rectFocus(btnRect);

    rectFocus.DeflateRect(4,4);

    if (!m_bMenuPushed)
        rectFocus.OffsetRect(m_bPushed,m_bPushed);

    rectFocus.right -= nDropBtnWidth;

    ////////////////////////////////////////
    // Button in a normal state           //
    ////////////////////////////////////////
    if (!m_bPushed || m_bMenuPushed)
    {
#ifdef _VISUALSTYLE_XP_H_
        if (g_xpStyle.IsAppThemed())
        {
            HTHEME hTheme = g_xpStyle.OpenThemeData(GetSafeHwnd(), L"BUTTON");
            g_xpStyle.DrawThemeBackground(hTheme, pDC->GetSafeHdc(),
                                          BP_PUSHBUTTON, PBS_NORMAL, &btnRect, 0);
            g_xpStyle.CloseThemeData(hTheme);
        }
        else
        {
#endif
            pDC->DrawFrameControl(&btnRect,DFC_BUTTON,DFCS_BUTTONPUSH);
#ifdef _VISUALSTYLE_XP_H_
        }
#endif
    }


    ////////////////////////////////////////
    // Default Button State               //
    ////////////////////////////////////////
    if ((m_bDefaultBtn || m_bPushed) && !bDisabled)
    {

        if (m_bPushed && !m_bMenuPushed)
        {
#ifdef _VISUALSTYLE_XP_H_
            if (g_xpStyle.IsAppThemed())
            {
                HTHEME hTheme = g_xpStyle.OpenThemeData(GetSafeHwnd(), L"BUTTON");
                g_xpStyle.DrawThemeBackground(hTheme, pDC->GetSafeHdc(),
                                              BP_PUSHBUTTON, PBS_PRESSED, &btnRect, 0);
                g_xpStyle.CloseThemeData(hTheme);
            }
            else
            {
#endif
                pDC->FrameRect(&lpDIS->rcItem,CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH)));
                pDC->FrameRect(&btnRect,CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH)));
#ifdef _VISUALSTYLE_XP_H_
            }
#endif
        }
    }
    ////////////////////////////////////////
    // State Hover                        //
    ////////////////////////////////////////
    if (m_bOverControl /*lpDIS->itemState & ODS_HOTLIGHT*/)
        if (!m_bMenuPushed)
        {
#ifdef _VISUALSTYLE_XP_H_
            if (g_xpStyle.IsAppThemed())
            {
                HTHEME hTheme = g_xpStyle.OpenThemeData(GetSafeHwnd(), L"BUTTON");
                g_xpStyle.DrawThemeBackground(hTheme, pDC->GetSafeHdc(),
                                              BP_PUSHBUTTON, PBS_HOT, &btnRect, 0);
                g_xpStyle.CloseThemeData(hTheme);
            }
#endif
        }

    ////////////////////////////////////////
    // State Focus                        //
    ////////////////////////////////////////
    if (lpDIS->itemState & ODS_FOCUS || m_bPushed)
        if (!m_bMenuPushed)
            pDC->DrawFocusRect(&rectFocus);


    ////////////////////////////////////////
    // Action Focus                       //
    ////////////////////////////////////////
    if ((lpDIS->itemAction & ODA_FOCUS))
        if (!m_bMenuPushed)
            pDC->DrawFocusRect(&rectFocus);


    ////////////////////////////////////////
    // Draw out bitmap                    //
    ////////////////////////////////////////

    // Draw out bitmap
    if (m_bLoaded)
    {
        if (!bDisabled)
        {
            m_IL.DrawIndirect(pDC,0,CPoint(6+m_bPushed,6+m_bPushed), CSize(m_bm.bmWidth, m_bm.bmHeight), CPoint(0,0),ILD_NORMAL);
        }
        else
        {
            pDC->DrawState(CPoint(6+m_bPushed,6+m_bPushed), CSize(m_bm.bmWidth, m_bm.bmHeight), m_hbmpDisabled, DST_BITMAP | DSS_DISABLED);
        }
    }


    ////////////////////////////////////////
    // Draw out text                      //
    ////////////////////////////////////////
    pDC->SelectObject(pFont);
    CRect rectText(rectFocus);
    rectFocus.left += m_bm.bmWidth + 2;

    CString strCaption;
    GetWindowText(strCaption);
    pDC->SetBkMode(TRANSPARENT);
    pDC->SetBkColor(GetSysColor(COLOR_BTNFACE));

    if (ODS_DISABLED & lpDIS->itemState)
    {
        rectFocus.OffsetRect(1,1);
        pDC->SetTextColor(GetSysColor(COLOR_WINDOW));
        pDC->DrawText(strCaption,rectFocus,DT_SINGLELINE|DT_CENTER|DT_VCENTER);

        rectFocus.OffsetRect(-1,-1);
        pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
        pDC->DrawText(strCaption,rectFocus,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
    }
    else
    {
        pDC->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
        pDC->DrawText(strCaption,rectFocus,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
    }


    CRect rectSplit(btnRect);
    rectSplit.DeflateRect(2,2);
    rectSplit.right -= nDropBtnWidth;


    ////////////////////////////////////////
    // Drop down split                    //
    ////////////////////////////////////////
    CPen brFace(PS_SOLID,1,GetSysColor(COLOR_3DSHADOW));
    pDC->SelectObject(&brFace);
    pDC->MoveTo(rectSplit.right, rectSplit.top);
    pDC->LineTo(rectSplit.right, rectSplit.bottom);


    CPen brLite(PS_SOLID,1,GetSysColor(COLOR_3DHILIGHT));
    pDC->SelectObject(&brLite);
    pDC->MoveTo(rectSplit.right+1 , rectSplit.top);
    pDC->LineTo(rectSplit.right+1, rectSplit.bottom);


    rectSplit.left = rectSplit.right;
    rectSplit.right += nDropBtnWidth;

    CPoint pt(rectSplit.CenterPoint());
    pt += CPoint(m_bPushed,m_bPushed);

    CPen penBlack(PS_SOLID, 1, bDisabled ? GetSysColor(COLOR_GRAYTEXT) : GetSysColor(COLOR_WINDOWTEXT));
    pDC->SelectObject(&penBlack);
    DrawArrow(pDC,pt);

    ////////////////////////////////////////
    // Drop down state                    //
    ////////////////////////////////////////
    if (m_bMenuPushed && !bDisabled)
    {
#ifdef _VISUALSTYLE_XP_H_
        rectSplit.DeflateRect(1,1);
#else
        rectSplit.InflateRect(1,1);
#endif
        pDC->DrawEdge(rectSplit,BDR_SUNKENOUTER, BF_RECT);
    }
}
void COptionTreeFontSelColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	// Validate
	ASSERT(lpDrawItemStruct);

	// Declare variables
	CDC* pDC  = CDC::FromHandle(lpDrawItemStruct->hDC);
	UINT state = lpDrawItemStruct->itemState;
    CRect rDraw = lpDrawItemStruct->rcItem;
	CRect rArrow;
	UINT uFrameState;

	// Active popup
	if (m_bPopupActive)
	{
		state |= ODS_SELECTED | ODS_FOCUS;
	}

	// Frame state
	uFrameState = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT;

	// Selected
	if (state & ODS_SELECTED)
	{
		uFrameState |= DFCS_PUSHED;
	}

	// Disabled
	if (state & ODS_DISABLED)
	{
		uFrameState |= DFCS_INACTIVE;
	}
	
	// Draw frame
	pDC->DrawFrameControl(&rDraw, DFC_BUTTON, uFrameState);


	// Offset rectangle if selected
	if (state & ODS_SELECTED)
	{
		rDraw.OffsetRect(1,1);
	}

	// Draw focus
	if (state & ODS_FOCUS) 
    {
		RECT rFocus = {rDraw.left, rDraw.top, rDraw.right - 1, rDraw.bottom};
  
        pDC->DrawFocusRect(&rFocus);
    }
	rDraw.DeflateRect(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE));

	// Draw arrow
	rArrow.left = rDraw.right - g_ciArrowSizeX - ::GetSystemMetrics(SM_CXEDGE) /2;
	rArrow.right = rArrow.left + g_ciArrowSizeX;
	rArrow.top = (rDraw.bottom + rDraw.top)/2 - g_ciArrowSizeY / 2;
	rArrow.bottom = (rDraw.bottom + rDraw.top)/2 + g_ciArrowSizeY / 2;
	DrawArrow(pDC, &rArrow, 0,(state & ODS_DISABLED) ? ::GetSysColor(COLOR_GRAYTEXT) : RGB(0,0,0));
	rDraw.right = rArrow.left - ::GetSystemMetrics(SM_CXEDGE)/2;

	// Draw seperator
	pDC->DrawEdge(&rDraw, EDGE_ETCHED, BF_RIGHT);
	rDraw.right -= (::GetSystemMetrics(SM_CXEDGE) * 2) + 1 ;
				  
	// Draw color
	if ((state & ODS_DISABLED) == 0)
	{
		pDC->FillSolidRect(&rDraw, (m_crColor == CLR_DEFAULT) ? m_crDefaultColor : m_crColor);

		::FrameRect(pDC->m_hDC, &rDraw, (HBRUSH)::GetStockObject(BLACK_BRUSH));
	}
}
Example #15
0
void CTabCtrlEx::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
    if(lpDrawItemStruct->CtlType == ODT_TAB)
    {
        CRect rect = lpDrawItemStruct->rcItem;
        INT nTabIndex = lpDrawItemStruct->itemID;
        if (nTabIndex < 0) return;

        TCHAR label[64];
        TC_ITEM tci;
        tci.mask = TCIF_TEXT|TCIF_IMAGE;
        tci.pszText = label;
        tci.cchTextMax = 63;
        GetItem(nTabIndex, &tci );

        CDC *pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
        if (!pDC) return;
        int nSavedDC = pDC->SaveDC();

        //填充背景色
        COLORREF rcBack;
        if (lpDrawItemStruct->itemState & CDIS_SELECTED  )
            rcBack = RGB(255, 255,255);
        else if(lpDrawItemStruct->itemState & (CDIS_DISABLED | CDIS_GRAYED) )
            rcBack = RGB(0, 255, 0);
        else
            rcBack = GetSysColor(COLOR_BTNFACE);
        pDC->FillSolidRect(rect, rcBack);

        rect.top += ::GetSystemMetrics(SM_CYEDGE);

        pDC->SetBkMode(TRANSPARENT);

        //绘制图片
        CImageList *pImageList = GetImageList();
        if (pImageList && tci.iImage >= 0)
        {
            rect.left += pDC->GetTextExtent(_T(" ")).cx;       // Margin

            // Get height of image so we
            IMAGEINFO info;
            pImageList->GetImageInfo(tci.iImage, &info);
            CRect ImageRect(info.rcImage);
            INT nYpos = rect.top;

            pImageList->Draw(pDC, tci.iImage, CPoint(rect.left, nYpos), ILD_TRANSPARENT);
            rect.left += ImageRect.Width();
        }

        //绘制字体
        COLORREF txtColor;
        if (lpDrawItemStruct->itemState & CDIS_SELECTED  )
        {
            rect.top -= ::GetSystemMetrics(SM_CYEDGE);

            txtColor = RGB(0,0,255);
        }
        else if(lpDrawItemStruct->itemState & (CDIS_DISABLED | CDIS_GRAYED) )
            txtColor = RGB(128, 128, 128);
        else
            txtColor = GetSysColor(COLOR_WINDOWTEXT);
        pDC->SetTextColor(txtColor);
		int r=rect.right;
		rect.right-=15;
        pDC->DrawText(label, rect, DT_SINGLELINE|DT_VCENTER|DT_CENTER);
		rect.right=r;
		rect.left=rect.right-17;
		rect.top+=3;
		rect.bottom-=6;
		pDC->DrawFrameControl(&rect,DFCS_CAPTIONCLOSE,DFCS_BUTTONPUSH);
        pDC->RestoreDC(nSavedDC);

    }
}
Example #16
0
void CXFMenuButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    // -[Feral]-----------------------------------------------------------
    // VALIDATION:
    ASSERT(lpDrawItemStruct != NULL);

    // -[Feral]-----------------------------------------------------------
    // Vars and Assignment
    CRect rect      = lpDrawItemStruct->rcItem;
    CDC *pDC        = CDC::FromHandle(lpDrawItemStruct->hDC);
    UINT uiState    = lpDrawItemStruct->itemState;
    CPen pen;
    CPen *ppenOld   = NULL;

    // -[Feral]-----------------------------------------------------------
    // set the pen color based on if we are disabled or not
    if( (uiState&ODS_DISABLED) )
    {
        pen.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_GRAYTEXT) );
    }
    else
    {
        pen.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNTEXT) );
    }


    // -[Feral]-----------------------------------------------------------
    // select the pen into the DC.
    ppenOld = pDC->SelectObject(&pen);


    // -[Feral]-----------------------------------------------------------
    // draw the border
    if( (uiState&ODS_SELECTED) )
    {
        pDC->DrawFrameControl(rect, DFC_BUTTON, DFCS_BUTTONPUSH|DFCS_PUSHED);
    }
    else
    {
        pDC->DrawFrameControl(rect, DFC_BUTTON, DFCS_BUTTONPUSH);
    }


    // -[Feral]-----------------------------------------------------------
    // Draw the Arrow...
    // Something like:
    // X
    // XX
    // XXX
    // XXXX
    // XXX
    // XX
    // X
    // In the Center of the button.
    CSize sizeArrow(4,7);
    CSize sizeOffsetTop(1,+1);          // size of the top stairsteps
    CSize sizeOffsetBottom(1,-1);       // size of the bottom stairsteps
    CPoint pointCenter( (rect.Width()/2), (rect.Height()/2) );
    CPoint pointStart( (pointCenter.x-(sizeArrow.cx/2) ), (pointCenter.y-(sizeArrow.cy/2) ) );
    CPoint pointStop ( (pointStart.x), (pointStart.y+sizeArrow.cy) );
    // -[Feral]-----------------------------------------------------------
    // start at the left and work to the right...
    for(int iInd=0; iInd<sizeArrow.cx; iInd++)
    {
        // -[Feral]-------------------------------------------------------
        // draw the lines
        pDC->MoveTo(pointStart);
        pDC->LineTo(pointStop);

        // -[Feral]-------------------------------------------------------
        // offset our points. (going right!)
        pointStart.Offset(sizeOffsetTop);
        pointStop .Offset(sizeOffsetBottom);
    }

    // -[Feral]-----------------------------------------------------------
    // Draw the focus rectangle if necessary.
    if( (uiState&ODS_FOCUS) )
    {
        CRect rectFocus(rect);
        rectFocus.DeflateRect(3,3);     // This looked prety close
        pDC->DrawFocusRect(rectFocus);
    }

    // -[Feral]-----------------------------------------------------------
    // Clean Up and Return
    pDC->SelectObject(ppenOld);         // Restore the pen
}
Example #17
0
void CDropListBox::DrawItem(LPDRAWITEMSTRUCT pDIStruct) 
{
	//
	// Set var's
	BOOL			bIsSelected = FALSE;
	BOOL			bIsDisabled = FALSE;
	BOOL			bIsChecked = FALSE;
	BOOL			bIsNew = FALSE; // 2002-08-19
	COLORREF		clrNormal = ::GetSysColor(COLOR_WINDOW);
	COLORREF		clrSelected = ::GetSysColor(COLOR_HIGHLIGHT);
	COLORREF		clrText = ::GetSysColor(COLOR_WINDOWTEXT);
	COLORREF		clrTextHilight = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
	COLORREF		clrBackground = ::GetSysColor(COLOR_HIGHLIGHT);
	COLORREF		clrTextDisabled = ::GetSysColor(COLOR_GRAYTEXT);
	PLIST_ITEM		pItem;

	CDC* pDC = CDC::FromHandle(pDIStruct->hDC);
	pItem = (PLIST_ITEM)GetItemDataPtr(pDIStruct->itemID);

	bIsDisabled = pItem->bDisabled;
	bIsChecked = pItem->bChecked;
	if( (pDIStruct->itemAction | ODA_SELECT) && (pDIStruct->itemState & ODS_SELECTED) )
		bIsSelected = TRUE;

	CRect rcItem = pDIStruct->rcItem;
	CRect rcBitmap = pDIStruct->rcItem;
	CRect rcText = pDIStruct->rcItem;
	CRect rcCenteredText = pDIStruct->rcItem;
	CRect rcCheck = pDIStruct->rcItem;

	pDC->SetBkMode(TRANSPARENT);
	pDC->SetTextColor(clrText);

	if( m_dwACBStyle & ACBS_CHECKED )
	{
		if( bIsChecked )
		{
			rcCheck.right = rcCheck.left + rcCheck.Height();
			pDC->DrawFrameControl( &rcCheck, DFC_MENU, DFCS_MENUCHECK );
		}
		rcText.left += rcItem.Height()-4;
		rcItem.left += rcItem.Height()-4;
	}

	//
	// Is item selected
	if( bIsSelected )
	{
		if( m_bSelectDisabled )
		{
			pDC->SetBkColor( clrBackground );
			pDC->SetTextColor( clrTextHilight );
			pDC->FillSolidRect( rcItem, clrSelected);
		}
		else
		if( m_bSelectDisabled && !bIsDisabled )
		{
			pDC->SetBkColor( clrBackground );
			pDC->SetTextColor( clrTextHilight );
			pDC->FillSolidRect( rcItem, clrSelected);
		}
		else
		if( !m_bSelectDisabled && !bIsDisabled )
		{
			pDC->SetBkColor( clrBackground );
			pDC->SetTextColor( clrTextHilight );
			pDC->FillSolidRect( rcItem, clrSelected);
		}
	}
	else
	{
		pDC->SetBkColor( clrNormal );
		pDC->SetTextColor( clrText );
		pDC->FillSolidRect( rcItem, clrNormal);
	}

	if( bIsDisabled )
	{
		pDC->SetTextColor(clrTextDisabled);
	}

	//
	// Draw text
	rcText.left += 2;
	pDC->DrawText( pItem->strText.c_str(), &rcText, DT_SINGLELINE|DT_VCENTER);
}
Example #18
0
//***********************************************************************
// Method:	CColorButton::DrawItem()
// Notes:	None.
//***********************************************************************
void CColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	ASSERT(lpDrawItemStruct);

	CDC*    pDC      = CDC::FromHandle(lpDrawItemStruct->hDC);
	UINT    state    = lpDrawItemStruct->itemState;
    CRect   rDraw    = lpDrawItemStruct->rcItem;
	CRect	rArrow;

	if (m_bPopupActive)
		state |= ODS_SELECTED|ODS_FOCUS;

	//******************************************************
	//**                  Draw Outer Edge
	//******************************************************
	UINT uFrameState = DFCS_BUTTONPUSH|DFCS_ADJUSTRECT;

	if (state & ODS_SELECTED)
		uFrameState |= DFCS_PUSHED;

	if (state & ODS_DISABLED)
		uFrameState |= DFCS_INACTIVE;
	
	pDC->DrawFrameControl(&rDraw,
						  DFC_BUTTON,
						  uFrameState);


	if (state & ODS_SELECTED)
		rDraw.OffsetRect(1,1);

	//******************************************************
	//**                     Draw Focus
	//******************************************************
	if (state & ODS_FOCUS) 
    {
		RECT rFocus = {rDraw.left,
					   rDraw.top,
					   rDraw.right - 1,
					   rDraw.bottom};
  
        pDC->DrawFocusRect(&rFocus);
    }

	rDraw.DeflateRect(::GetSystemMetrics(SM_CXEDGE),
					  ::GetSystemMetrics(SM_CYEDGE));

	//******************************************************
	//**                     Draw Arrow
	//******************************************************
	rArrow.left		= rDraw.right - g_ciArrowSizeX - ::GetSystemMetrics(SM_CXEDGE) /2;
	rArrow.right	= rArrow.left + g_ciArrowSizeX;
	rArrow.top		= (rDraw.bottom + rDraw.top)/2 - g_ciArrowSizeY / 2;
	rArrow.bottom	= (rDraw.bottom + rDraw.top)/2 + g_ciArrowSizeY / 2;

	DrawArrow(pDC,
			  &rArrow,
			  0,
			  (state & ODS_DISABLED) 
			  ? ::GetSysColor(COLOR_GRAYTEXT) 
			  : RGB(0,0,0));


	rDraw.right = rArrow.left - ::GetSystemMetrics(SM_CXEDGE)/2;

	//******************************************************
	//**                   Draw Separator
	//******************************************************
	pDC->DrawEdge(&rDraw,
				  EDGE_ETCHED,
				  BF_RIGHT);

	rDraw.right -= (::GetSystemMetrics(SM_CXEDGE) * 2) + 1 ;
				  
	//******************************************************
	//**                     Draw Color
	//******************************************************
	if ((state & ODS_DISABLED) == 0)
	{
		pDC->FillSolidRect(&rDraw,
						   (m_Color == CLR_DEFAULT)
						   ? m_DefaultColor
						   : m_Color);

		::FrameRect(pDC->m_hDC,
					&rDraw,
					(HBRUSH)::GetStockObject(BLACK_BRUSH));
	}
}
Example #19
0
void CTreeOptionsCtrlEx::OnCreateImageList()
{
	CDC* pDCScreen = CDC::FromHandle(::GetDC(HWND_DESKTOP)); // explicitly use screen-dc, for proper RTL support
	if (pDCScreen)
	{
		const int iBmpWidth = 16;
		const int iBmpHeight = 16;
		const int iBitmaps = 13;
		CBitmap bmpControls;
		if (bmpControls.CreateCompatibleBitmap(pDCScreen, iBmpWidth*iBitmaps, iBmpHeight))
		{
			if (m_ilTree.Create(iBmpWidth, iBmpHeight, m_uImageListColorFlags | ILC_MASK, 0, 1))
			{
				CDC dcMem;
				if (dcMem.CreateCompatibleDC(pDCScreen))
				{
					HTHEME hTheme = (g_xpStyle.IsThemeActive() && g_xpStyle.IsAppThemed()) ? g_xpStyle.OpenThemeData(NULL, L"BUTTON") : NULL;
					CBitmap* pOldBmp = dcMem.SelectObject(&bmpControls);
					dcMem.FillSolidRect(0, 0, iBmpWidth*iBitmaps, iBmpHeight, GetSysColor(COLOR_WINDOW));

					//int iCtrlWidth = iBmpWidth - 2;
					//int iCtrlHeight = iBmpHeight - 2;
					int iCtrlWidth = 16 - 3;
					int iCtrlHeight = 16 - 3;
					int iCtrlLeft = (iBmpWidth - iCtrlWidth) / 2;
					int iCtrlTop = (iBmpHeight - iCtrlHeight) / 2;

					// checkbox
					CRect rcBmp(0, 0, 0+iBmpWidth, 0+iBmpHeight);
					CRect rcCtrl(iCtrlLeft, iCtrlTop, iCtrlLeft+iCtrlWidth, iCtrlTop+iCtrlHeight);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
					}
					else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_FLAT);

					// checkbox checked
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*1);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
					}
					else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_FLAT);

					// radio
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*2);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_UNCHECKEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_UNCHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_FLAT);

					// radio checked
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*3);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_CHECKEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_CHECKEDNORMAL, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_FLAT);

					// checkbox disabled
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*4);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_UNCHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_INACTIVE | DFCS_FLAT);

					// checkbox checked disabled
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*5);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_CHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT);

					// radio disabled
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*6);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_UNCHECKEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_UNCHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_INACTIVE | DFCS_FLAT);

					// radio checked disabled
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*7);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_RADIOBUTTON, RBS_CHECKEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, RBS_CHECKEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTONRADIO | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT);

					// checkbox checked tri-state
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*8);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDNORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDNORMAL, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_FLAT);

					// checkbox checked tri-state disabled 
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*9);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDDISABLED, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, BP_CHECKBOX, CBS_MIXEDDISABLED, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_BUTTON, DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT);

					ASSERT( TREEOPTSCTRLIMG_EDIT == 11 );
					rcBmp.MoveToX(iBmpWidth*11);
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*11);
					CFont font;
					if (font.CreatePointFont(10, _T("Courier")))
					{
						CFont* pOldFont = dcMem.SelectObject(&font);
						dcMem.TextOut(rcCtrl.left+2, rcCtrl.top, _T("I"));
						dcMem.SelectObject(pOldFont);
					}
					CRect rcEdge(rcBmp);
					rcEdge.top += 1;
					rcEdge.bottom -= 1;
					dcMem.DrawEdge(&rcEdge, EDGE_ETCHED, BF_RECT);

					if (hTheme){
						g_xpStyle.CloseThemeData(hTheme);
						hTheme = NULL;
					}

					hTheme = (g_xpStyle.IsThemeActive() && g_xpStyle.IsAppThemed()) ? g_xpStyle.OpenThemeData(NULL, L"COMBOBOX") : NULL;
					rcCtrl.MoveToX(iCtrlLeft+iBmpWidth*12);
					if (hTheme){
						g_xpStyle.DrawThemeBackground(hTheme, dcMem, CP_DROPDOWNBUTTON, CBXS_NORMAL, &rcCtrl, NULL);
						g_xpStyle.DrawThemeEdge(hTheme, dcMem, CP_DROPDOWNBUTTON, CBXS_NORMAL, &rcCtrl, 0, 0, NULL);
					} else
						dcMem.DrawFrameControl(&rcCtrl, DFC_SCROLL, DFCS_SCROLLCOMBOBOX | DFCS_FLAT);

					dcMem.SelectObject(pOldBmp);
					m_ilTree.Add(&bmpControls, RGB(255,0,255));
					if (hTheme)
						g_xpStyle.CloseThemeData(hTheme);
				}
			}
		}
		::ReleaseDC(HWND_DESKTOP, *pDCScreen);
	}
}
///////////////////////////////////////////////////////////////////////////////
//
// CreateCheckboxImageList()
//
// Purpose:     Create themed checkbox image list
//
// Parameters:  pDC          - pointer to device context for drawing
//              imagelist    - image list to create
//              nSize        - height and width of images
//              crBackground - fill color
//
// Returns:     BOOL         - TRUE if image list created OK
//
BOOL CreateCheckboxImageList(CDC *pDC, 
							 CImageList& imagelist, 
							 int nSize, 
							 COLORREF crBackground)
{
	ASSERT(pDC);
	ASSERT(nSize > 0);

	BOOL rc = FALSE;

	///////////////////////////////////////////////////////////////////////////
	//
	// CHECKBOX IMAGES
	//
	// From MSDN:  "To indicate that the item has no state image, set the
	//             index to zero. This convention means that image zero in 
	//             the state image list cannot be used as a state image."
	//
	// Note that comparable hot image = cold image index OR 8.
	// Disabled state = index OR 4.
	
	struct CHECKBOXDRAWDATA
	{
		TCHAR * pszDesc;	// description for debugging
		int nStateId;		// for DrawThemeBackground
		UINT nState;		// for DrawFrameControl
	} 
	cbdd[] =
	{
		// cold -----------------------------------------------------------------------------------
/*0000*/_T("unused"),				0,						0,
/*0001*/_T("unchecked normal"),		CBS_UNCHECKEDNORMAL,	DFCS_BUTTONCHECK | DFCS_FLAT,
/*0010*/_T("checked normal"),		CBS_CHECKEDNORMAL,		DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_FLAT,
/*0011*/_T("tri-state normal"),		CBS_MIXEDNORMAL,		DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_FLAT,
/*0100*/_T("unused"),				0,						0,
/*0101*/_T("unchecked disabled"),	CBS_UNCHECKEDDISABLED,	DFCS_BUTTONCHECK | DFCS_INACTIVE | DFCS_FLAT,
/*0110*/_T("checked disabled"),		CBS_CHECKEDDISABLED,	DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT,
/*0111*/_T("tri-state disabled"),	CBS_MIXEDDISABLED,		DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT,

		// hot ------------------------------------------------------------------------------------
/*1000*/_T("unused"),				0,						0,
/*1001*/_T("unchecked normal"),		CBS_UNCHECKEDHOT,		DFCS_BUTTONCHECK | DFCS_FLAT,
/*1010*/_T("checked normal"),		CBS_CHECKEDHOT,			DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_FLAT,
/*1011*/_T("tri-state normal"),		CBS_MIXEDHOT,			DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_FLAT,
/*1100*/_T("unused"),				0,						0,
/*1101*/_T("unchecked disabled"),	CBS_UNCHECKEDDISABLED,	DFCS_BUTTONCHECK | DFCS_INACTIVE | DFCS_FLAT,
/*1110*/_T("checked disabled"),		CBS_CHECKEDDISABLED,	DFCS_BUTTONCHECK | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT,
/*1111*/_T("tri-state disabled"),	CBS_MIXEDDISABLED,		DFCS_BUTTON3STATE | DFCS_CHECKED | DFCS_INACTIVE | DFCS_FLAT,

		NULL, 0, 0		// last entry
	};

	if (pDC && (nSize > 0))
	{
		const int nBmpWidth = nSize;
		const int nBmpHeight = nSize;
		const int nImages = sizeof(cbdd)/sizeof(cbdd[0]);
		ASSERT(nImages == 17);

		if (imagelist.GetSafeHandle())
			imagelist.DeleteImageList();

		CBitmap bmpCheckboxes;

		if (bmpCheckboxes.CreateCompatibleBitmap(pDC, nBmpWidth * nImages, 
				nBmpHeight))
		{
			if (imagelist.Create(nBmpWidth, nBmpHeight, ILC_COLOR32 | ILC_MASK, 
					nImages, 1))
			{
				CDC dcMem;
				if (dcMem.CreateCompatibleDC(pDC))
				{
					HTHEME hTheme = NULL;
					hTheme = (g_xpStyle.IsThemeActive() && 
							  g_xpStyle.IsAppThemed()) ? 
							  g_xpStyle.OpenThemeData(NULL, L"BUTTON") : NULL;
					CBitmap* pOldBmp = dcMem.SelectObject(&bmpCheckboxes);
					dcMem.FillSolidRect(0, 0, nBmpWidth*nImages, nBmpHeight, 
						crBackground);

					int nImageWidth  = nBmpWidth - 2;		// allow 2 for border
					int nImageHeight = nBmpHeight - 2;
					int nImageLeft   = (nBmpWidth - nImageWidth) / 2;
					int nImageTop    = (nBmpHeight - nImageHeight) / 2;

					CRect rectImage(nImageLeft, 
									nImageTop, 
									nImageLeft+nImageWidth, 
									nImageTop+nImageHeight);

					for (int i = 0; cbdd[i].pszDesc != NULL; i++)
					{
						if (_tcscmp(cbdd[i].pszDesc, _T("unused")) == 0)
						{
							// unused image slot
							// note that we skip the first image - they are 1-based
						}
						else
						{
							if (hTheme)
							{
								g_xpStyle.DrawThemeBackground(hTheme, dcMem, 
									BP_CHECKBOX, cbdd[i].nStateId, &rectImage, 
									NULL);
								g_xpStyle.DrawThemeEdge(hTheme, dcMem, 
									BP_CHECKBOX, cbdd[i].nStateId, &rectImage, 0, 0, 
									NULL);
							}
							else
							{
								dcMem.DrawFrameControl(&rectImage, DFC_BUTTON, 
									cbdd[i].nState);
							}
						}

						rectImage.left  += nBmpWidth;
						rectImage.right += nBmpWidth;
					}

					if (hTheme)
					{
						g_xpStyle.CloseThemeData(hTheme);
						hTheme = NULL;
					}

					dcMem.SelectObject(pOldBmp);
					imagelist.Add(&bmpCheckboxes, RGB(255,0,255));
					if (hTheme)
						g_xpStyle.CloseThemeData(hTheme);

					rc = TRUE;
				}
				else
				{
					TRACE(_T("ERROR - failed to create DC\n"));
				}
			}
			else
			{
				TRACE(_T("ERROR - failed to create image list\n"));
			}
		}
		else
		{
			TRACE(_T("ERROR - failed to create bitmap\n"));
		}
	}
	else
	{
		TRACE(_T("ERROR - bad parameters\n"));
	}
	return rc;
}
CRect TranscriptWindow::DrawButton(
    CDC& dc, CRect& rect, bool centre, const char* text, Button button, bool enable)
{
    // Select the font and measure the text in it
    CFont* oldFont = dc.SelectObject(theApp.GetFont(InformApp::FontDisplay));
    CSize size = dc.GetTextExtent(text);

    // Adjust the width of the button
    if (centre)
    {
        rect.left = rect.right-(size.cx/2)-m_layout.margin.cx;
        rect.right = rect.left+size.cx+m_layout.margin.cx*2;
    }
    else
        rect.left = rect.right-size.cx-m_layout.margin.cx*2;

    // Determine the button's state
    CPoint mousePoint = GetCurrentMessage()->pt;
    ScreenToClient(&mousePoint);
    bool over = (rect.PtInRect(mousePoint) != 0);
    bool down = (m_buttonDown == button);

    if (theOS.IsAppThemed())
    {
        // Open the button theme
        HTHEME theme = theOS.OpenThemeData(this,L"Button");
        if (theme)
        {
            UINT state = PBS_NORMAL;
            if (!enable)
                state = PBS_DISABLED;
            else if (over && down)
                state = PBS_PRESSED;
            else if (down)
                state = PBS_HOT;
            else if (over && (m_buttonDown == Button()))
                state = PBS_HOT;

            // Draw the themed control frame
            theOS.DrawThemeBackground(theme,&dc,BP_PUSHBUTTON,state,rect);

            // Get the background size
            CRect backRect(rect);
            theOS.GetThemeBackgroundContentRect(theme,&dc,BP_PUSHBUTTON,state,backRect);

            // Draw the themed button text
            CStringW textW(text);
            theOS.DrawThemeText(theme,&dc,BP_PUSHBUTTON,state,textW,
                                DT_CENTER|DT_VCENTER|DT_SINGLELINE,DTT_GRAYED,backRect);

            // Close the button theme
            theOS.CloseThemeData(theme);
        }
    }
    else
    {
        UINT state = DFCS_BUTTONPUSH;
        if (!enable)
            state |= DFCS_INACTIVE;
        else if (over && down)
            state |= DFCS_PUSHED;

        // Draw the control background
        dc.DrawFrameControl(rect,DFC_BUTTON,state);

        // Work out the bounding rectangle for the button text
        CRect textRect(rect);
        textRect.DeflateRect((rect.Width()-size.cx)/2,(rect.Height()-size.cy)/2);
        if (state & DFCS_PUSHED)
        {
            textRect.top++;
            textRect.left++;
        }

        // Draw the button text
        dc.DrawState(textRect.TopLeft(),textRect.Size(),text,
                     (state & DFCS_INACTIVE) ? DSS_DISABLED : DSS_NORMAL,TRUE,0,(HBRUSH)0);
    }

    // Select the previous font
    dc.SelectObject(oldFont);

    // Store the button rectangle
    if (enable)
        m_buttons.push_back(std::make_pair(rect,button));

    // Return the button rectangle
    return rect;
}
void COptionTreeSpinnerButton::OnPaint()
{
    // Make sure options aren't NULL
    if (m_otSpinnerOption == NULL)
    {
        return;
    }

    // Declare variables
    CPaintDC dc(this);
    CDC* pDCMem = new CDC;
    CBitmap bpMem;
    CBitmap *bmOld;
    COLORREF crOld;
    HGDIOBJ hOldBrush;
    int nOldBack;
    CRect rcButtonTop, rcButtonBottom, rcClient;
    CString strText;
    HGDIOBJ hOld;

    // Get client rectangle
    GetClientRect(rcClient);

    // Calculate rectangle
    // -- Top
    rcButtonTop.top = rcClient.top;
    rcButtonTop.left = (rcClient.right - 2) - OT_SPINNER_WIDTH;
    rcButtonTop.right = rcClient.right - 2;
    rcButtonTop.bottom = rcClient.Height() / 2;
    m_rcButtonTop = rcButtonTop;
    // -- Bottom
    rcButtonBottom.top = rcButtonTop.bottom;
    rcButtonBottom.left = (rcClient.right - 2) - OT_SPINNER_WIDTH;
    rcButtonBottom.right = rcClient.right - 2;
    rcButtonBottom.bottom = rcClient.bottom;
    m_rcButtonBottom = rcButtonBottom;

    // Create DC
    pDCMem->CreateCompatibleDC(&dc);

    // Create bitmap
    bpMem.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height());

    // Select bitmap
    bmOld = pDCMem->SelectObject(&bpMem);

    // Set background mode
    nOldBack = pDCMem->SetBkMode(TRANSPARENT);

    // Set text color
    crOld = pDCMem->SetTextColor(GetSysColor(COLOR_WINDOWTEXT));

    // Select font
    hOld = pDCMem->SelectObject(m_otSpinnerOption->GetNormalFont());

    // Draw control background
    hOldBrush = pDCMem->SelectObject(GetSysColorBrush(COLOR_BTNFACE));
    pDCMem->PatBlt(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), PATCOPY);

    // Wrap around
    if (GetOption(OT_EDIT_WRAPAROUND) == TRUE)
    {
        // -- Draw top button
        // -- -- Pressed
        if (m_bTopPressed == TRUE)
        {
            pDCMem->DrawFrameControl(&rcButtonTop, DFC_SCROLL, DFCS_PUSHED | DFCS_SCROLLUP);
        }
        // -- -- UnPressed
        else
        {
            pDCMem->DrawFrameControl(&rcButtonTop, DFC_SCROLL, DFCS_SCROLLUP);
        }

        // -- Draw bottom button
        // -- -- Pressed
        if (m_bBottomPressed == TRUE)
        {
            pDCMem->DrawFrameControl(&rcButtonBottom, DFC_SCROLL, DFCS_PUSHED | DFCS_SCROLLDOWN);
        }
        // -- -- UnPressed
        else
        {
            pDCMem->DrawFrameControl(&rcButtonBottom, DFC_SCROLL, DFCS_SCROLLDOWN);
        }
    }
    // No Wrap around
    else
    {
        // -- Draw top button
        if (_GetValue() >= m_dRangeTop)
        {
            pDCMem->DrawFrameControl(&rcButtonTop, DFC_SCROLL, DFCS_INACTIVE | DFCS_SCROLLUP);
        }
        else
        {
            // -- -- Pressed
            if (m_bTopPressed == TRUE)
            {
                pDCMem->DrawFrameControl(&rcButtonTop, DFC_SCROLL, DFCS_PUSHED | DFCS_SCROLLUP);
            }
            // -- -- UnPressed
            else
            {
                pDCMem->DrawFrameControl(&rcButtonTop, DFC_SCROLL, DFCS_SCROLLUP);
            }
        }

        // -- Draw bottom button
        if (_GetValue() <= m_dRangeBottom)
        {
            pDCMem->DrawFrameControl(&rcButtonBottom, DFC_SCROLL, DFCS_INACTIVE | DFCS_SCROLLDOWN);
        }
        else
        {
            // -- -- Pressed
            if (m_bBottomPressed == TRUE)
            {
                pDCMem->DrawFrameControl(&rcButtonBottom, DFC_SCROLL, DFCS_PUSHED | DFCS_SCROLLDOWN);
            }
            // -- -- UnPressed
            else
            {
                pDCMem->DrawFrameControl(&rcButtonBottom, DFC_SCROLL, DFCS_SCROLLDOWN);
            }
        }
    }

    // Copy to screen
    dc.BitBlt(0, 0, rcClient.Width(), rcClient.Height(), pDCMem, 0, 0, SRCCOPY);

    // Restore GDI ojects
    pDCMem->SelectObject(bmOld);
    pDCMem->SelectObject(hOldBrush);
    pDCMem->SetBkMode(nOldBack);
    pDCMem->SelectObject(hOld);
    pDCMem->SetTextColor(crOld);

    // Delete objects
    if (pDCMem->GetSafeHdc() != NULL)
    {
        pDCMem->DeleteDC();
    }
    delete pDCMem;
    if (bpMem.GetSafeHandle() != NULL)
    {
        bpMem.DeleteObject();
    }
}