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


C++ CBrush函数代码示例

本文整理汇总了C++中CBrush函数的典型用法代码示例。如果您正苦于以下问题:C++ CBrush函数的具体用法?C++ CBrush怎么用?C++ CBrush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: FillRect

void CFavoriteOrganizeDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	if(nIDCtl != IDC_LIST2) return;

	int nItem = lpDrawItemStruct->itemID;
	CRect rcItem = lpDrawItemStruct->rcItem;

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

	if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
	{
		FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
		FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
	}
	else
	{
		CBrush b;
		b.CreateSysColorBrush(COLOR_WINDOW);
		FillRect(pDC->m_hDC, rcItem, b);
	}

	CString str = m_list.GetItemText(nItem, 0);

	pDC->SetTextColor(0);
	pDC->TextOut(rcItem.left+3, (rcItem.top+rcItem.bottom - pDC->GetTextExtent(str).cy)/2, str);
}
开发者ID:Strongc,项目名称:playasa,代码行数:26,代码来源:FavoriteOrganizeDlg.cpp

示例2: GetClientRect

void CClock::DrawTime( CDC *pDc )
{
	CRect  rtClient;
	GetClientRect(&rtClient);
	CDC  dcTransparent;
	dcTransparent.CreateCompatibleDC(pDc);
	CBitmap bitTransParent;
	bitTransParent.CreateCompatibleBitmap(pDc, rtClient.Width(),rtClient.Height());
	dcTransparent.SelectObject(&bitTransParent);

	// 		CRect rectReal(ix1, iy1, ix2, iy2);
	dcTransparent.FillSolidRect(rtClient, RGB(255, 255, 255));
	// 		dcTransparent.Draw3dRect(rectReal, RGB(111, 147, 188), RGB(111, 147, 188));

	dcTransparent.BeginPath();
	dcTransparent.MoveTo(rtClient.Width()/2, rtClient.Height()/2);
	dcTransparent.LineTo(rtClient.Width()/2-80, rtClient.Height()/2);

	float   fEnd = 90.0f;
	dcTransparent.AngleArc(rtClient.Width()/2, rtClient.Height()/2, 120, -180.0f, 270.0f);
	dcTransparent.LineTo(rtClient.Width()/2, rtClient.Height()/2);

	dcTransparent.EndPath();
	CRgn rgn;
	rgn.CreateFromPath(&dcTransparent);
	dcTransparent.FillRgn(&rgn, &CBrush(RGB(188, 199, 216)));

	//内
	dcTransparent.BeginPath();
	dcTransparent.MoveTo(rtClient.Width()/2, rtClient.Height()/2);
	dcTransparent.LineTo(rtClient.Width()/2-40, rtClient.Height()/2);

	dcTransparent.AngleArc(rtClient.Width()/2, rtClient.Height()/2, 40, -180.0f, 270.0f);
	dcTransparent.LineTo(rtClient.Width()/2, rtClient.Height()/2);

	dcTransparent.EndPath();
	CRgn rgn1;
	rgn1.CreateFromPath(&dcTransparent);
	dcTransparent.FillRgn(&rgn1, &CBrush(RGB(255, 255, 0)));

	if( ::AlphaBlend == 0 )
	{
		pDc->StretchBlt(0, 0, rtClient.Width(), rtClient.Height(), 
			&dcTransparent, 0, 0, rtClient.Width(), rtClient.Height(), SRCINVERT );

	}else{

		BLENDFUNCTION bf;    
		memset( &bf, 0, sizeof( bf ) );
		bf.SourceConstantAlpha = 0x9f; //半透明
		bf.BlendOp = AC_SRC_OVER;

		::TransparentBlt(pDc->GetSafeHdc(), 0, 0, rtClient.Width(), rtClient.Height(), 
			dcTransparent.GetSafeHdc( ), 0, 0, rtClient.Width(), rtClient.Height(), RGB(255, 255, 255));
		// 			::AlphaBlend( memDC.GetSafeHdc(), 0, 0, rtClient.Width(), rtClient.Height(), 
		// 				dcTransparent.GetSafeHdc( ), 0, 0, rtClient.Width(), rtClient.Height(), bf );  
	}
	bitTransParent.DeleteObject();
	dcTransparent.DeleteDC();
}
开发者ID:njustccy,项目名称:NjustTool,代码行数:60,代码来源:CClock.cpp

示例3: FindPos

void CPlayerPlaylistBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    if (nIDCtl != IDC_PLAYLIST) {
        return;
    }

    int nItem = lpDrawItemStruct->itemID;
    CRect rcItem = lpDrawItemStruct->rcItem;
    POSITION pos = FindPos(nItem);
    bool fSelected = pos == m_pl.GetPos();
    CPlaylistItem& pli = m_pl.GetAt(pos);

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

    if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
        FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
        FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
    } else {
        FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
    }

    COLORREF textcolor = fSelected ? 0xff : 0;
    if (pli.m_fInvalid) {
        textcolor |= 0xA0A0A0;
    }

    CString time = !pli.m_fInvalid ? m_list.GetItemText(nItem, COL_TIME) : _T("Invalid");
    CSize timesize(0, 0);
    CPoint timept(rcItem.right, 0);
    if (time.GetLength() > 0) {
        timesize = pDC->GetTextExtent(time);
        if ((3 + timesize.cx + 3) < rcItem.Width() / 2) {
            timept = CPoint(rcItem.right - (3 + timesize.cx + 3), (rcItem.top + rcItem.bottom - timesize.cy) / 2);

            pDC->SetTextColor(textcolor);
            pDC->TextOut(timept.x, timept.y, time);
        }
    }

    CString fmt, file;
    fmt.Format(_T("%%0%dd. %%s"), (int)log10(0.1 + m_pl.GetCount()) + 1);
    file.Format(fmt, nItem + 1, m_list.GetItemText(nItem, COL_NAME));
    CSize filesize = pDC->GetTextExtent(file);
    while (3 + filesize.cx + 6 > timept.x && file.GetLength() > 3) {
        file = file.Left(file.GetLength() - 4) + _T("...");
        filesize = pDC->GetTextExtent(file);
    }

    if (file.GetLength() > 3) {
        pDC->SetTextColor(textcolor);
        pDC->TextOut(rcItem.left + 3, (rcItem.top + rcItem.bottom - filesize.cy) / 2, file);
    }
}
开发者ID:Azpidatziak,项目名称:mpc-hc,代码行数:53,代码来源:PlayerPlaylistBar.cpp

示例4: UNREFERENCED_PARAMETER

void CEditListEditor::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    if (nIDCtl != IDC_EDITLIST) {
        return;
    }

    int nItem = lpDrawItemStruct->itemID;
    CRect rcItem = lpDrawItemStruct->rcItem;
    POSITION pos = m_editList.FindIndex(nItem);

    if (pos) {
        bool fSelected = (pos == m_curPos);
        UNREFERENCED_PARAMETER(fSelected);
        CClip& curClip = m_editList.GetAt(pos);
        CString strTemp;

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

        if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
            FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
            FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
        } else {
            FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
        }

        COLORREF textcolor = RGB(0, 0, 0);
        if (!curClip.HaveIn() || !curClip.HaveOut()) {
            textcolor = RGB(255, 0, 0);
        }

        for (int i = 0; i < COL_MAX; i++) {
            m_list.GetSubItemRect(nItem, i, LVIR_LABEL, rcItem);
            pDC->SetTextColor(textcolor);
            switch (i) {
                case COL_INDEX:
                    strTemp.Format(_T("%d"), nItem + 1);
                    pDC->DrawText(strTemp, rcItem, DT_CENTER | DT_VCENTER);
                    break;
                case COL_IN:
                    pDC->DrawText(curClip.GetIn(), rcItem, DT_CENTER | DT_VCENTER);
                    break;
                case COL_OUT:
                    pDC->DrawText(curClip.GetOut(), rcItem, DT_CENTER | DT_VCENTER);
                    break;
                case COL_NAME:
                    pDC->DrawText(curClip.GetName(), rcItem, DT_LEFT | DT_VCENTER);
                    break;
            }
        }
    }
}
开发者ID:Murder66,项目名称:mpc-hc-master,代码行数:51,代码来源:EditListEditor.cpp

示例5: point_top

int KGListCtrl::DrawRect(
						 CDC* dc, CRect rt, COLORREF colorFrame, COLORREF colorBack, int nFlag
						 )
{
	int nLen = (int)((rt.right - rt.left) * 0.5); 

	CPoint point_top(rt.left + nLen, rt.top + 2); 
	CPoint point_dwn(rt.left + nLen, rt.bottom - 1);
	CPoint point_lef(rt.left + 2, rt.top + nLen);
	CPoint point_rig(rt.right - 1, rt.top + nLen);

	dc->FillRect(&rt, &CBrush(colorBack));
	CPen pen(PS_SOLID, 1, colorFrame);
	dc->SelectObject(&pen);
	dc->MoveTo(rt.left,  rt.top);
	dc->LineTo(rt.right, rt.top);
	dc->LineTo(rt.right, rt.bottom);
	dc->LineTo(rt.left,  rt.bottom);
	dc->LineTo(rt.left,  rt.top);

	if (nFlag)
	{
		dc->MoveTo(point_top);
		dc->LineTo(point_dwn);
		dc->MoveTo(point_lef);
		dc->LineTo(point_rig);
	}
	else
	{
		dc->MoveTo(point_lef);
		dc->LineTo(point_rig);
	}

	return true;
}
开发者ID:viticm,项目名称:pap2,代码行数:35,代码来源:KGListCtrl.cpp

示例6: RGB

void CBarShader::FillRect(CDC *dc, LPRECT rectSpan, float fRed, float fGreen,
						  float fBlue, bool bFlat) {
	if(bFlat) {
		COLORREF color = RGB((int)(fRed + .5f), (int)(fGreen + .5f), (int)(fBlue + .5f));
		dc->FillRect(rectSpan, &CBrush(color));
	} else {
		if (m_Modifiers == NULL || (m_used3dlevel!=thePrefs.Get3DDepth() && !m_bIsPreview) )
			BuildModifiers();
		RECT rect = *rectSpan;
		int iTop = rect.top;
		int iBot = rect.bottom;
		int iMax = HALF(m_iHeight);
		for(int i = 0; i < iMax; i++) {
			CBrush cbNew(RGB((int)(fRed * m_Modifiers[i] + .5f), (int)(fGreen * m_Modifiers[i] + .5f), (int)(fBlue * m_Modifiers[i] + .5f)));
			
			rect.top = iTop + i;
			rect.bottom = iTop + i + 1;
			dc->FillRect(&rect, &cbNew);

			rect.top = iBot - i - 1;
			rect.bottom = iBot - i;
			dc->FillRect(&rect, &cbNew);
		}
	}
}
开发者ID:LjApps,项目名称:eMule-VeryCD,代码行数:25,代码来源:BarShader.cpp

示例7: dc

void CCJControlBar::OnNcPaint() 
{
    // get window DC that is clipped to the non-client area
    CWindowDC dc(this);

	CRect rectWindow;
	GetWindowRect(rectWindow);
	ScreenToClient(rectWindow);

	CRect rectClient;
	GetClientRect(rectClient);
	rectClient.OffsetRect(-rectWindow.left, -rectWindow.top);
	dc.ExcludeClipRect(rectClient);
	
    // draw borders in non-client area
	rectWindow.OffsetRect(-rectWindow.left, -rectWindow.top);
	DrawBorders(&dc, rectWindow);
	
    // erase parts not drawn
	dc.IntersectClipRect(rectWindow);
	
    // erase NC background the hard way
	dc.FillRect(rectWindow, &CBrush(::GetSysColor(COLOR_BTNFACE)));
	
    // paint the mobile edge
    dc.Draw3dRect(m_rectBorder, ::GetSysColor(COLOR_BTNHIGHLIGHT),
        ::GetSysColor(COLOR_BTNSHADOW));
	
    ReleaseDC(&dc);
}
开发者ID:ZhaoboMeng,项目名称:k-line-print,代码行数:30,代码来源:CJControlBar.cpp

示例8: ScreenToClient

void CEditListCtrl::OnPaint() 
{	
	//CPaintDC dc(this); // device context for painting	
	
	if (m_iSubItem >= 0 && m_edtItemEdit.m_hWnd)	
	{
		CRect	rect;
		CRect	rcEdit;
		m_edtItemEdit.GetWindowRect(rcEdit);
		ScreenToClient(rcEdit);

		GetSubItemRect(m_iItem, m_iSubItem, LVIR_LABEL, rect);

		//当文本编辑框缩小时,擦除露出的项文本高亮部分
		if (rcEdit.right < rect.right)
		{
			rect.left = rcEdit.right;
			CClientDC dc(this);
			dc.FillRect(rect, &CBrush(::GetSysColor(COLOR_WINDOW)));
			ValidateRect(rect);
		}

	}

	CListCtrl::OnPaint();
}
开发者ID:Fance,项目名称:T3000_Building_Automation_System,代码行数:26,代码来源:EditListCtrl.cpp

示例9: dc

void KGClassButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CClientDC dc(this);
	COLORREF color;
	CRect rect;
	CPen  pen;

	GetClientRect(&rect);
	dc.FillRect(&rect, &CBrush(RGB(255, 255, 255)));
	if (m_nStateFlag)
	{
		color = RGB(255, 2, 2);
	}
	else
	{
		color = RGB(100, 100, 100);
	}

	pen.CreatePen(PS_SOLID, 2, color);
	dc.SelectObject(&pen);

	if (m_hButtonIcon)
	{
		dc.DrawIcon(rect.left, rect.top, m_hButtonIcon);
	}

	if (m_nSelFlag)
	{
		dc.MoveTo(rect.left, rect.top);
		dc.LineTo(rect.right, rect.top);
		dc.LineTo(rect.right, rect.bottom);
		dc.LineTo(rect.left, rect.bottom);
		dc.LineTo(rect.left, rect.top - 2);
	}
}
开发者ID:viticm,项目名称:pap2,代码行数:35,代码来源:KGObjectEditerProjectListDlg.cpp

示例10: KG_PROCESS_ERROR

void KGIniListCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

    LPKGLISTITEM pItem = (LPKGLISTITEM)GetItemData(lpDrawItemStruct->itemID);
    USER_ITEM_DATA itemData;

    KGListCtrl::DrawItem(lpDrawItemStruct);

    KG_PROCESS_ERROR(pItem);

    pItem->GetStructData(&itemData, sizeof(itemData));

    if (itemData.dwValueType == VALUE_COLOR)
    {
        COLORREF colorRef = (COLORREF)atoi(itemData.szPropertyValue);
        CRect rect;
        GetSubItemRect(
            lpDrawItemStruct->itemID, 1, LVIR_BOUNDS, rect
        );
        rect.left += 12;
        rect.top  += 2;
        rect.bottom -= 1;
        rect.right = rect.left + rect.Height();
        pDC->FillRect(&rect, &CBrush(colorRef));
        pDC->Draw3dRect(&rect, RGB(100, 100, 100), RGB(100, 100, 100));
    }

Exit0:
    return;
}
开发者ID:viticm,项目名称:pap2,代码行数:31,代码来源:KGInIFileEditDlg.cpp

示例11: SetItemBkColor

void CMyListCtrl::SetItemBkColor(CDC* pDC,BOOL bHighlight,int iItem,const CRect& rect)
{
	// Draw the background color
	if( bHighlight )
	{
		pDC->SetBkColor( m_clrSelItemBK);
		pDC->FillRect(rect, &CBrush( m_clrSelItemBK));
	}
	else
	{
		vector<int>::iterator ite=find(m_vecSearchedItems.begin(),m_vecSearchedItems.end(),iItem);
		if (ite!=m_vecSearchedItems.end())
		{
			pDC->SetBkColor( m_colorSearchHightLight);
			pDC->FillRect(rect, &CBrush( m_colorSearchHightLight));
		}
		else
		{
			if( iItem % 2 )
			{
				pDC->SetBkColor( m_clrOddItemBK);
				pDC->FillRect(rect, &CBrush( m_clrOddItemBK));
			}
			else
			{
				pDC->SetBkColor( m_clrEvenItemBK );
				pDC->FillRect(rect, &CBrush( m_clrEvenItemBK ));
			}
		}
	}
/*
	if( m_bDrawItemTopLine )
	{
		//Item上画一条分割线
		CRect rcTopLine = rect;
		rcTopLine.bottom = rcTopLine.top + 1;
		pDC->FillRect(rcTopLine, &CBrush(RGB(241,246,249)));
	}
*/
	if( !bHighlight && m_bDrawHoverRow && m_iCurrentCursorItem == iItem )
	{
		CDibBitmap *pDib = ::AfxGetUIManager()->UIGetSkinMgr()->GetDibBmp("ListHoverBK");
		pDib->SetCDibRect(rect);
		pDib->Draw(pDC, true);
	}
}
开发者ID:2Dou,项目名称:PlayBox,代码行数:46,代码来源:MyListCtrl.cpp

示例12: GetClientRect

BOOL CBaseDlg::OnEraseBkgnd(CDC* pDC)
{
	CRect clientRect;
	GetClientRect(&clientRect);

	pDC->FillRect(&clientRect, &CBrush(m_bkColor));
	return FALSE;
}
开发者ID:HGRun,项目名称:MFC_UI_REPO,代码行数:8,代码来源:CBaseDlg.cpp

示例13: GetClientRect

BOOL CQnStatic::OnEraseBkgnd(CDC* pDC)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	CRect rect;
	GetClientRect(rect);
	pDC->FillRect(rect, &CBrush(RGB(233,233,233)));
	return CStatic::OnEraseBkgnd(pDC);
}
开发者ID:Omgan,项目名称:code4me,代码行数:8,代码来源:QnStatic.cpp

示例14: switch

void CColorSlide::PaintBK(CRect aRect,HDC hMemDC)
{
	::SetBkMode(hMemDC,TRANSPARENT);



	COLORREF lcolorBack = ::GetBkColor(hMemDC);
	gBitMapOperate.FillRectangle(hMemDC, aRect, lcolorBack, true ) ;

	RECT lrcTrack     = aRect;
	lrcTrack.top     += 2;
	lrcTrack.bottom   = lrcTrack.top+7;
	lrcTrack.left    += TRACKBAR_INTERVAL;
	lrcTrack.right   -= TRACKBAR_INTERVAL;

	if( (m_iStatePosX)>=0 )
	{
		CDC::FromHandle(hMemDC)->FrameRect( &lrcTrack,&CBrush( gWndColor.getColor(SLIDER_CTROL)->structColBase->colFrame1) );
		::InflateRect(&lrcTrack,-1,-1);
		switch(m_SlideType)
		{
		case LIGHT_SLIDE:
			gBitMapOperate.FillRectangleLight( hMemDC,lrcTrack,m_colBegain,m_colEnd,m_nHue, gBitMapOperate.edoHorizontal, true, (lrcTrack.right - lrcTrack.left) );
			break;
		case HUE_SLIDE:
			gBitMapOperate.FillRectangleHue( hMemDC,lrcTrack,m_colBegain,m_colEnd, gBitMapOperate.edoHorizontal, true, (lrcTrack.right - lrcTrack.left) );
			break;
		case PERCENT_SLIDE:
			{
				CRect lrect1 = lrcTrack;
				lrect1.right = lrect1.left>m_iStatePosX? lrect1.left:m_iStatePosX;
				CDC::FromHandle(hMemDC)->FillRect( lrect1, &CBrush(m_colBegain ) );
				
				CRect lrect2 = lrcTrack;
				lrect2.left = lrect2.left>m_iStatePosX? lrect2.left:m_iStatePosX ;
				CDC::FromHandle(hMemDC)->FillRect( lrect2, &CBrush( m_colEnd ) );
			}
			break;
		case S_SLIDE:
			gBitMapOperate.FillRectangleS( hMemDC,lrcTrack,m_colBegain,m_colEnd,m_nHue, gBitMapOperate.edoHorizontal, true, (lrcTrack.right - lrcTrack.left) );
        break;
		default:
			break;
		}
	}
}
开发者ID:2Dou,项目名称:PlayBox,代码行数:46,代码来源:ColorSlide.cpp

示例15: GetWindowText

void CDrawButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	
	//判断控件类型是否为按钮类型
	if (lpDrawItemStruct->CtlType == ODT_BUTTON)
	{
		CDC dc;

		
		dc.Attach(lpDrawItemStruct->hDC);	//附加设备上下文句柄
		//获取按钮状态
		int nState = lpDrawItemStruct->itemState;
		//获取按钮区域
		CRect btnRC = lpDrawItemStruct->rcItem;
		CString szBtnText;
		GetWindowText(szBtnText);	//获取按钮文本

		CPoint pt;
		GetCursorPos(&pt);
		ScreenToClient(&pt);
		
		COLORREF clrText;	//文本颜色
		clrText = RGB(0, 0, 0);
		COLORREF clrBK = RGB(220, 220, 220);		//背景颜色

		if (nState & ODS_SELECTED || nState & ODS_FOCUS)
		{
			clrBK = RGB(222, 231, 239);
		}
		if (m_nBtnState == 1)
		{
			clrText = RGB(255, 0, 255);
		}
		
		dc.SetTextColor(clrText);

		dc.FillRect(btnRC, &CBrush(clrBK));
		dc.FrameRect(btnRC, &CBrush(RGB(140, 158, 176)));


		dc.SetBkMode(TRANSPARENT);
		dc.DrawText(szBtnText, btnRC, DT_SINGLELINE|DT_CENTER|DT_VCENTER|DT_WORD_ELLIPSIS);
		dc.Detach();	//分离句柄
	}	
}
开发者ID:dulton,项目名称:nampu,代码行数:45,代码来源:DrawButton.cpp


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