当前位置: 首页>>代码示例>>C++>>正文


C++ CDC::DrawFrameControl方法代码示例

本文整理汇总了C++中CDC::DrawFrameControl方法的典型用法代码示例。如果您正苦于以下问题:C++ CDC::DrawFrameControl方法的具体用法?C++ CDC::DrawFrameControl怎么用?C++ CDC::DrawFrameControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CDC的用法示例。


在下文中一共展示了CDC::DrawFrameControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawItem

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);
    }
}
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:60,代码来源:ColourPicker.cpp

示例2: OnNcPaint

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;
}
开发者ID:jjayne,项目名称:nSIGHTS,代码行数:41,代码来源:WindowSelector.cpp

示例3: DrawItem

// 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);
	}
}
开发者ID:shaovoon,项目名称:outline-text,代码行数:41,代码来源:MyButton.cpp

示例4: DrawItem

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);
    }
}
开发者ID:Conti-Meissner,项目名称:busmaster,代码行数:48,代码来源:ColorSelector.cpp

示例5: GetWindowDC

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
	{
开发者ID:rusingineer,项目名称:EmulePlus,代码行数:48,代码来源:DialogMinTrayBtn.hpp

示例6: PreDrawItem

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);
}
开发者ID:killbug2004,项目名称:ghost2013,代码行数:42,代码来源:XTPCustomizeToolbarsPage.cpp

示例7: DrawItem

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);	
	}
}
开发者ID:bugou,项目名称:test,代码行数:36,代码来源:BmpButton.cpp

示例8: DrawItem

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);
}
开发者ID:killbug2004,项目名称:cosps,代码行数:87,代码来源:DropListBox.cpp

示例9: DrawGripper

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 );
	}

}
开发者ID:mixxit,项目名称:solinia,代码行数:79,代码来源:cool_dialog_bar.cpp

示例10: DrawCaption

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);
	}

}
开发者ID:0anion0,项目名称:IBN,代码行数:95,代码来源:OFSNcDlg.cpp

示例11: DrawItem

////////////////////////////////////////////////////////////////////////////////
//
// 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                        //
    ////////////////////////////////////////
//.........这里部分代码省略.........
开发者ID:ibrahimelhadeg,项目名称:trainops,代码行数:101,代码来源:CoolBtn.cpp

示例12: DrawItem

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));
	}
}
开发者ID:gaopan461,项目名称:DataEditor,代码行数:72,代码来源:OptionTreeFontSelColorButton.cpp

示例13: DrawItem

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);

    }
}
开发者ID:myosg,项目名称:MyOsgMfcTest,代码行数:74,代码来源:TabCtrlEx.cpp

示例14: DrawItem

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
}
开发者ID:darwinbeing,项目名称:trade,代码行数:88,代码来源:MenuButton.cpp

示例15: DrawItem

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);
}
开发者ID:nk39,项目名称:mototool,代码行数:86,代码来源:DropListBox.cpp


注:本文中的CDC::DrawFrameControl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。