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


C++ CBrush::CreateSolidBrush方法代码示例

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


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

示例1: DrawGradient

void CProgressCtrlX::DrawGradient(const CDrawInfo& info, const CRect &rcGrad, const CRect &rcClip, COLORREF clrStart, COLORREF clrEnd)
{
	// Split colors to RGB chanels, find chanel with maximum difference 
	// between the start and end colors. This distance will determine 
	// number of steps of gradient
	int r = (GetRValue(clrEnd) - GetRValue(clrStart));
	int g = (GetGValue(clrEnd) - GetGValue(clrStart));
	int b = (GetBValue(clrEnd) - GetBValue(clrStart));
	int nSteps = max(abs(r), max(abs(g), abs(b)));
	// if number of pixels in gradient less than number of steps - 
	// use it as numberof steps
	int nPixels = rcGrad.Width();
	nSteps = min(nPixels, nSteps);
	if(nSteps == 0) nSteps = 1;

	float rStep = (float)r/nSteps;
	float gStep = (float)g/nSteps;
	float bStep = (float)b/nSteps;

	r = GetRValue(clrStart);
	g = GetGValue(clrStart);
	b = GetBValue(clrStart);

	BOOL fLowColor = info.pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE;
	if(!fLowColor && nSteps > 1)
		if(info.pDC->GetDeviceCaps(BITSPIXEL)*info.pDC->GetDeviceCaps(PLANES) < 8)
			nSteps = 1; // for 16 colors no gradient

	float nWidthPerStep = (float)rcGrad.Width() / nSteps;
	CRect rcFill(rcGrad);
	CBrush br;
	// Start filling
	for (int i = 0; i < nSteps; i++) 
	{
		rcFill.left = rcGrad.left + (int)(nWidthPerStep * i);
		rcFill.right = rcGrad.left + (int)(nWidthPerStep * (i+1));
		if(i == nSteps-1)	//last step (because of problems with float)
			rcFill.right = rcGrad.right;

		if(rcFill.right < rcClip.left)
			continue; // skip - band before cliping rect
		
		// clip it
		if(rcFill.left < rcClip.left)
			rcFill.left = rcClip.left;
		if(rcFill.right > rcClip.right)
			rcFill.right = rcClip.right;

		COLORREF clrFill = RGB(r + (int)(i * rStep),
		                       g + (int)(i * gStep),
		                       b + (int)(i * bStep));
		if(fLowColor)
		{
			br.CreateSolidBrush(clrFill);
			// CDC::FillSolidRect is faster, but it does not handle 8-bit color depth
			info.pDC->FillRect(&ConvertToReal(info, rcFill), &br);
			br.DeleteObject();
		}
		else
			info.pDC->FillSolidRect(&ConvertToReal(info, rcFill), clrFill);
		if(rcFill.right >= rcClip.right)
			break; // stop filling if we reach current position
	}
}
开发者ID:rusingineer,项目名称:eMule-mephisto-mod,代码行数:64,代码来源:ProgressCtrlX.cpp

示例2: OnPaint

void CJPWordWnd::OnPaint()
{
#define JP_PAINT_X_ 5
    CPaintDC dc(this);
    CDC dcMemory;
    CBitmap bitmap;
    if (!dc.IsPrinting())
    {
        if (dcMemory.CreateCompatibleDC(&dc))
        {
            if (bitmap.CreateCompatibleBitmap(&dc,clientRect.right,clientRect.bottom))
            {
                dcMemory.SelectObject(&bitmap);
                /*CBrush br;
                br.CreateSysColorBrush(CSCB);
                br.CreateSolidBrush(RGB(200,200,200));
                dcMemory.FillRect(&clientRect,&br);*/
                //设置画笔
                CPen pen;
                pen.CreatePen(PS_SOLID, 0, RGB(255, 0, 0));
                CPen *pOldPen = dcMemory.SelectObject(&pen);
                //设置画刷
                CBrush brush;
                brush.CreateSolidBrush( RGB(200,255,000) );
                CBrush* pOldBrush = dcMemory.SelectObject(&brush);
                //填充圆角矩形
                dcMemory.RoundRect(clientRect.left+4, clientRect.top+4, clientRect.right-4, clientRect.bottom-4, 20, 20);

                // 将字体选进DC
                CFont* pOldFont = dcMemory.SelectObject(&fontZhuYin);
                //设置字体背景色
                COLORREF oldBkColor = dcMemory.SetBkColor(RGB(200,255,0));
                COLORREF oldTextColor = dcMemory.SetTextColor(RGB(0,0,0));

                //设置裁剪区域
                CRgn rgn ;
                rgn.CreateRoundRectRgn(clientRect.left+6, clientRect.top+6, clientRect.right-8, clientRect.bottom-8, 20, 20);
                dcMemory.SelectClipRgn(&rgn);


                if(bInit)
                {
                    //cout<<"paint^"<<endl;
                    allBaseX = JP_PAINT_X_;
                    allBaseY = 0;
                    //一行总体高度,换行时使用
                    int rowHeight = -1;
                    //单个注音字符的绘制宽度,绘制声调线时用
                    int charZhuYinWidth = -1;
                    // 注音字符高度
                    int charZhuYinHeight = -1;

                    // 单词字符高度
                    int charWordHeight = -1;

                    //声调线高度
                    int toneHeight = 0;//10 ;

                    //绘制声调线的纵向基准
                    int toneBaseY = allBaseY + 5 ;

                    //绘制注音的纵向基准
                    int zhuYinBaseY = toneBaseY + toneHeight + 2 ;

                    //绘制单词的纵向基准
                    int wordBaseY = -1 ;


                    //循环绘制各个单词和注音
                    for(int i=0 ; i< jpword.wordCount ; i++ )
                    {
                        //取得当前单词
                        CString currentWord = CString( jpword.getWordAt(i).c_str());
                        //取得当前注音
                        CString currentZhuYin = CString( jpword.getZhuYinAt(i).c_str());
                        //取得单词长度(字符数)
                        int wordLen = jpword.getWordLengthAt(i);
                        //取得注音长度(字符数)
                        int zhuYinLen = jpword.getZhuYinLengthAt(i);
                        //将注音字体选进DC
                        dcMemory.SelectObject(&fontZhuYin);
                        //计算注音占据的矩形区域
                        CRect rcZhuYin = CRect(0,0,0,0);
                        dcMemory.DrawText( currentZhuYin, &rcZhuYin, DT_CALCRECT);
                        // 计算字符的宽度和高度
                        if(zhuYinLen > 0)
                        {
                            //获取注音字符的绘制宽度
                            charZhuYinWidth = rcZhuYin.Width() / zhuYinLen;
                            //获取注音字符的绘制高度
                            charZhuYinHeight = rcZhuYin.Height();
                        }
                        //当前注音为空
                        else
                        {
                            //用字符わ来计算
                            dcMemory.DrawText( _T("わ"), &rcZhuYin, DT_CALCRECT);
                            //获取注音字符的绘制宽度
                            charZhuYinWidth = rcZhuYin.Width();
                            //获取注音字符的绘制高度
//.........这里部分代码省略.........
开发者ID:gyk001,项目名称:JPWord,代码行数:101,代码来源:JPWordWnd.cpp

示例3: OnPaint

void CHyperLink::OnPaint()
{
	if (m_bMovingWindow)
	{
		return;
	}

	CBufferDC dc(this); // device context for painting

	dc.SaveDC();

	dc.SetMapMode(MM_TEXT);

	dc.SetBkMode(TRANSPARENT);

	dc.SelectObject(m_hFont);

	dc.SetBkColor(m_crBackGround);

	CRect rc;
    GetClientRect(&rc);
	CBrush cb;
	cb.CreateSolidBrush(m_crBackGround);
	dc.SelectObject(&cb);

	CBrush cb2;
	cb2.CreateSysColorBrush(COLOR_BTNFACE);
	dc.FillRect(&rc,&cb2);
	cb2.DeleteObject();

	CPen p;

	BOOL bWndTxt = FALSE;
	if (m_lpLinkText == NULL)
	{
		bWndTxt = TRUE;
		int nlen = GetWindowTextLength();
		m_lpLinkText = new TCHAR[nlen+1];
		m_lpLinkText[nlen] = (TCHAR)0;
		GetWindowText(m_lpLinkText,nlen+1);
	}

	GetWindowRect(rc);
	GetParent()->ScreenToClient(&rc);

	SIZE iconSz    = GetFirstIcon();
	SIZE iconSpace = { 0 };
	iconSpace.cx   = iconSz.cx;
	iconSpace.cy   = iconSz.cy;

	if (m_bMouseIn)
	{
		int i = 0;
		i++;
	}

	if (m_bLockInPosition)
	{
		iconSpace = GetBiggestIcon();
	}

	CSize sz = dc.GetTextExtent(m_lpLinkText,(int)_tcslen(m_lpLinkText));

	int x = rc.left;
	int y = sz.cy + 2;

	int* nlOff = NULL;
	int* nlXl  = NULL;
	int  nlXlM = sz.cx;
	int  nlc   = 0;
	size_t len = _tcslen(m_lpLinkText);

	if (m_bMultiline)
	{
		while (len > 0 && m_lpLinkText[len-1] == _T('\n'))
		{
			len--;
		}

		if (len > 0)
		{
			while (len--)
			{
				if (m_lpLinkText[len] == _T('\n'))
				{
					nlc++;
				}
			}
		}

		if (nlc > 0)
		{
			nlc++;
			len      = _tcslen(m_lpLinkText);
			nlOff    = new int[nlc];
			nlXl     = new int[nlc];
			nlXlM    = 0;
			int nlc2 = nlc;

			while (len > 0 && m_lpLinkText[len-1] == _T('\n'))
//.........这里部分代码省略.........
开发者ID:radtek,项目名称:project4more,代码行数:101,代码来源:HyperLink.cpp

示例4: OnPaint

void CGuiGroupBox::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	CRect rc;
	GetClientRect(rc);
	CBrush cb;
	CFont m_cfont;
	CString m_caption;
	CPen cpshadow(PS_SOLID,1,GuiDrawLayer::GetRGBColorShadow());
	cb.CreateSolidBrush(m_clrface);
	GetWindowText(m_caption);
	if ((m_style == ALING_LEFT) || (m_style == ALING_RIGHT))
		m_cfont.CreateFont( -11,0,0,0,400,0,0,0,0,1,2,1,34,"Verdana");
	else
		m_cfont.CreateFont(-11,0,900,900,400,0,0,0,0,1,2,1,34,"Verdana");	
	
	//********************************************************
	CFont* m_fontOld=dc.SelectObject(&m_cfont);
	CSize SizeCad=dc.GetTextExtent(m_caption);
	SizeCad.cx+=2;
	CRect rCText=rc;
	rc.DeflateRect(1,1);
	rc.top+=6;
	
	//orientar la cadena*************************************

		
	if (m_style == ALING_LEFT)
	{
		rCText.left+=6;
		rCText.bottom=rCText.top+SizeCad.cy+1;
		rCText.right=rCText.left+SizeCad.cx+1;
	}
	else if (m_style == ALING_RIGHT)
	{
		rCText.right-=6;
		rCText.left=rCText.right-SizeCad.cx+1;
		rCText.bottom=rCText.top+SizeCad.cy+1;
	}
	else if (m_style == ALING_DOWN)
	{
		rCText.bottom-=6;
		rCText.left=-7;
		rCText.top=rCText.bottom-SizeCad.cx;
		rCText.right=rCText.left+SizeCad.cy+1;
	}
	else if (m_style == ALING_UP)
	{
		rCText.top+=10;
		rCText.left=-7;
		rCText.right=rCText.left+SizeCad.cy+1;
		rCText.bottom=rCText.top+SizeCad.cx+7;
		
	}
	//********************************************************
	CPen* pOld=dc.SelectObject(&cpshadow);
	//linea superior
	dc.MoveTo(rc.left+2,rc.top);
	dc.LineTo(rc.right-2,rc.top);
	//linea vertical izquierda
	dc.MoveTo(rc.left,rc.top+2);
	dc.LineTo(rc.left,rc.bottom-2);
	//linea vertical derecha
	dc.MoveTo(rc.right,rc.top+2);
	dc.LineTo(rc.right,rc.bottom-2);
	//linea horizontal inferior
	dc.MoveTo(rc.left+2,rc.bottom);
	dc.LineTo(rc.right-2,rc.bottom);

	//ahora se dibujan los vertices

	//l,t
	dc.MoveTo(rc.left+2,rc.top);
	dc.LineTo(rc.left,rc.top+2);
	//r,t
	dc.MoveTo(rc.right-2,rc.top);
	dc.LineTo(rc.right,rc.top+2);
	//l,b
	dc.MoveTo(rc.left,rc.bottom-2);
	dc.LineTo(rc.left+2,rc.bottom);
	//r,b
	dc.MoveTo(rc.right-2,rc.bottom);
	dc.LineTo(rc.right,rc.bottom-2);
	
	//sentido del mensaje
	
	int nMode = dc.SetBkMode(TRANSPARENT);
	dc.FillRect(rCText,&cb);
	dc.SetTextColor(GuiDrawLayer::GetRGBCaptionXP());
	int cont=SizeCad.cx;
	if (m_style == ALING_DOWN || m_style == ALING_UP)
		dc.TextOut(rCText.left,rCText.bottom-2,m_caption);
	else
		dc.TextOut(rCText.left,rCText.top,m_caption);
 	dc.SetBkMode(nMode);
	// Modified By SunZhenyu
	dc.SelectObject(m_fontOld);
	dc.SelectObject(pOld);
}
开发者ID:darwinbeing,项目名称:trade,代码行数:99,代码来源:GuiGroupBox.cpp

示例5: OnPaint

void CGradientProgressCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	if(m_nCurrentPosition<=m_nLower||m_nCurrentPosition>=m_nUpper)
	{
		CRect rect;
		GetClientRect(rect);
		CBrush brush;
		brush.CreateSolidBrush(::GetSysColor(COLOR_3DFACE));
		dc.FillRect(&rect,&brush);
		VERIFY(brush.DeleteObject());
		return;
	}
	CRect rectClient;
	GetClientRect(rectClient);
	float maxWidth((float)m_nCurrentPosition/(float)m_nUpper*(float)rectClient.right);
/*	//绘制
	DrawGradient(&dc,rectClient,(int)maxWidth);
	//显示进程条进度文字
	if(m_bShowPercent)
	{
		CString percent;
		percent.Format("%d%%",(int)(100*(float)m_nCurrentPosition/m_nUpper));
		dc.SetTextColor(m_clrText);
		dc.SetBkMode(TRANSPARENT);
		dc.DrawText(percent,&rectClient,DT_VCENTER|DT_CENTER|DT_SINGLELINE);
	}
*/
	// Do not call CProgressCtrl::OnPaint() for painting messages
	/////////////////////////////
    
	CPen * pWhitePen=CPen::FromHandle((HPEN)GetStockObject(WHITE_PEN));
//	CPen * pBlackPen=CPen::FromHandle((HPEN)GetStockObject(BLACK_PEN));

	dc.SelectObject(pWhitePen);
	//创建笔画
	CPen BorderPen1(PS_SOLID,1, RGB( 0xff, 0xcf, 0xa7) );
	CPen * pOldPen1= dc.SelectObject(&BorderPen1);

	CBrush brush,*oldbrush;
	CBrush brush1;

	brush1.CreateSolidBrush(RGB( 0xff, 0xcf, 0xa7));

	oldbrush=dc.SelectObject(&brush1);
	dc.Rectangle( 0, 0, rectClient.right, rectClient.bottom);
	dc.SelectObject(oldbrush);
	dc.SelectObject(pOldPen1);
	BorderPen1.DeleteObject();

	brush.CreateSolidBrush(RGB(255,255,255));		// 白色
	oldbrush=dc.SelectObject(&brush);
	dc.Ellipse( 0, 0, rectClient.bottom, rectClient.bottom);
	dc.Ellipse( rectClient.right - rectClient.Height(), 0, rectClient.right, rectClient.bottom);
	dc.Rectangle( rectClient.Height()/2, 0, rectClient.right - rectClient.Height()/2, rectClient.bottom);

	dc.SelectObject(oldbrush);

//	CBrush brush2;
//--------------------------------------

	if ( maxWidth > rectClient.Height())
	{
	//	CPen * pRedPen=CPen::FromHandle((HPEN)GetStockObject(DKGRAY_BRUSH));
		//创建笔画
		CPen BorderPen(PS_SOLID,1, RGB(128, 0, 0) );
		CPen * pOldPen= dc.SelectObject(&BorderPen);

//		dc.SelectObject(pRedPen);
		CBrush brush2;
		brush2.CreateSolidBrush(RGB(128, 0, 0));
		oldbrush=dc.SelectObject(&brush2);
		dc.Ellipse( 0, 0, rectClient.bottom, rectClient.bottom);
		dc.Rectangle( rectClient.Height()/2, 0, maxWidth, rectClient.bottom);
		dc.SelectObject(oldbrush);
		
		//清理资源
		VERIFY(brush2.DeleteObject());
		dc.SelectObject(pOldPen);
		BorderPen.DeleteObject();
	}
//--------------------------------------
	VERIFY(brush1.DeleteObject());
	VERIFY(brush.DeleteObject());

}
开发者ID:anyboo,项目名称:project,代码行数:88,代码来源:GradientProgressCtrl.cpp

示例6: DrawItem

void CGuiToolButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC*  pdc= CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect rc=lpDrawItemStruct->rcItem;
	UINT  uState=lpDrawItemStruct->itemState;
	CBrush cb;
	
	if( uState & ODS_SELECTED) //the button is pressed
	{
		if(m_StyleDisplay==GUISTYLE_2003 || m_StyleDisplay == GUISTYLE_2003MENUBTN)
				cb.CreateSolidBrush(GuiDrawLayer::m_Theme? RGB(249,200,102):GuiDrawLayer::GetRGBPressBXP());
			else
				cb.CreateSolidBrush(GuiDrawLayer::GetRGBPressBXP());

	}	
	else
		if (m_bMouserOver)
		{
			if(m_StyleDisplay==GUISTYLE_2003 || m_StyleDisplay== GUISTYLE_2003MENUBTN)
				cb.CreateSolidBrush(GuiDrawLayer::m_Theme? RGB(252,230,186):GuiDrawLayer::GetRGBFondoXP());
			else
				cb.CreateSolidBrush(GuiDrawLayer::GetRGBFondoXP());

		}
		else
		{
		
			if(m_StyleDisplay==GUISTYLE_2003)
			{
				if (m_Transparent && m_StyleDisplay )
					cb.CreateStockObject(NULL_BRUSH);
				else
				{
					CGradient M(CSize(rc.Width(),rc.Height()+1));	
					M.PrepareReverseVertTab(pdc,m_StyleDisplay);
					M.Draw(pdc,rc.left,rc.top,0,0,rc.Width(),rc.Height(),SRCCOPY);	
				}
			}
			else
				if (m_StyleDisplay== GUISTYLE_2003MENUBTN)
					cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace(m_StyleDisplay));
				else
					cb.CreateSolidBrush(m_clColor);
			
		}
	
	if (( uState & ODS_SELECTED) || m_bMouserOver )
	{
		pdc->Draw3dRect(rc,GuiDrawLayer::GetRGBCaptionXP(),GuiDrawLayer::GetRGBCaptionXP());
		rc.DeflateRect(1,1);
		
	}
	else if(m_ScrollButton || m_bSimple)
	{
		pdc->Draw3dRect(rc,GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorShadow());
		rc.DeflateRect(1,1);
	}

	if (m_Transparent )
		pdc->FillRect(rc,&cb);


	int calculodify;
	calculodify=rc.Height()-(m_SizeImage.cy);
	calculodify/=2;
	int nHeigh=calculodify+(m_bShowDark?1:0);
	int nWidth=m_ScrollButton?rc.Width()/2 :2;
	CPoint m_point=CPoint(nWidth,nHeigh);
	
	if (m_SizeImage.cx > 2)
	{
		if(m_bMouserOver == 1 && !(uState & ODS_DISABLED) && !(uState & ODS_SELECTED) && m_bShowDark)
		{
			CPoint p(m_point.x+1,m_point.y+1);
			pdc->DrawState(p,m_SizeImage,m_Icon,DSS_MONO,CBrush (GuiDrawLayer::GetRGBColorShadow()));
			m_point.x-=1; m_point.y-=1;
		}
		pdc->DrawState (m_point, m_SizeImage,m_Icon,
					(uState==ODS_DISABLED?DSS_DISABLED:DSS_NORMAL),(CBrush*)NULL);
	}
	if (m_SizeText.cx > 2)
	{
		int nMode = pdc->SetBkMode(TRANSPARENT);
		CRect rectletra=rc;
		int nt=m_ScrollButton?0:8;
		rectletra.left+=m_SizeImage.cx+nt;
		CPoint pt=CSize(rectletra.top,rectletra.left);
		if (uState & ODS_DISABLED)
			pdc->DrawState(pt, m_SizeText, m_szText, DSS_DISABLED, TRUE, 0, (CBrush*)NULL);
		else
		{
			if(m_bMouserOver != 1) 
				pdc->SetTextColor(m_clrFont);
			pdc->DrawText(m_szText,rectletra,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
		}
		pdc->SetBkMode(nMode);
	}
	
	// TODO:  Add your code to draw the specified item
}
开发者ID:ZhaoboMeng,项目名称:k-line-print,代码行数:100,代码来源:GuiToolButton.cpp

示例7: drawHeader

void CLogGraph::drawHeader(CDC& dc)
{
	XTPPaintManager()->GradientFill(&dc, m_rectHeader,m_crHeaderBack, RGB(0,0,0), FALSE);

	CPen* pOldPen, pen;
	CFont* pOldFont;
	CString fmt, s;
	int i;

	if (m_nScaleIndex != -1)
		drawScale(dc, m_nScaleIndex, m_rectScale, DT_RIGHT);

	if (m_nScaleIndex2 != -1)
		drawScale(dc, m_nScaleIndex2, m_rectScale2, DT_LEFT);

	// draw Header (로그 시작점, 로그 끝점 표시)

	CString tmp;

	pOldFont = dc.SelectObject(&m_fontHeader);
	dc.SetTextColor(m_crHeader);

	if (!m_bLoad)return;
	//short* a = new short [lib->mque_reclen(m_hQue)]; //////////////
	tdata* tp = getTptr(m_nCurrentPos);
	// read date
//	lib->mque_getn(m_hQue, m_nCurrentPos+1, a);
	m_tStart = tp->time;
	s = tformat("%Y-%m-%d\r\n%H:%M:%S", m_tStart);
	tmp.Format("%s\r\n%d", s, m_nCurrentPos);
	dc.DrawText(tmp, &m_rectHeader, DT_LEFT);

//	lib->mque_getn(m_hQue, getWndQueLastPos()-1, a);
	tp = getTptr(getWndQueLastPos()-1);
//	m_tEnd = lib->mque_time(m_hQue);
//	s = tformat("%Y-%m-%d\r\n%H:%M:%S", (int)m_tEnd);
	tmp.Format("%s\r\n%d", s, getWndQueLastPos());
	dc.DrawText(tmp, &m_rectHeader, DT_RIGHT);
//	delete a;

	// draw Header (nav button, zoom)
	
	int nav[4][20] = {		// 20x20 짜리 nav button
		{ 1,1,  4,1,  4,8,  18,1,  18,19,  4,12,  4,19,  1,19,  1,1,  0,0 },		// home
		{ 1,10,  10,1,  10,8,  19,1,  19,19,  10,12,  10,19,  1,10,  0,0 },			// pgup
		{ 1,1,   10,8,  10,1,  19,10,  10,19,  10,12,   1,19,  1,1,  0,0 },			// pgdn
		{ 1,1,  16,8,  16,1,  19,1,  19,19,  16,19,  16,12,  1,19,  1,1,  0,0 }		// end
	};

	CRect r = m_rectHeader;
	int w = 20;				// button width & height
	int iw = w - 4;		// icon size

	CBrush brush;
	CRgn rgn;
	CPoint pt[20];

	brush.CreateSolidBrush(RGB(255, 100, 100));
	pen.CreatePen(PS_SOLID, 1, RGB(255, 255, 255));
	pOldPen = dc.SelectObject(&pen);
	r.left = r.Width() / 2 - (w * 4) / 2;
	r.right = r.left + w * 4;
	r.bottom = r.top + w;
	int x = r.left;
	for (i = 0; i < 4; i++) {
		CRect rect = r;
		rect.left = x + 1;
		rect.right = x + w - 1;
		rect.top++;
		rect.bottom--;
		switch (i) {
			case 0 : m_rectHome = rect; break;
			case 1 : m_rectPgUp = rect; break;
			case 2 : m_rectPgDn = rect; break;
			case 3 : m_rectEnd = rect; break;
		}

		XTPPaintManager()->GradientFill(&dc, &rect, RGB(100,100,100), RGB(0,0,0), FALSE);
		int j;
		for (j = 0; nav[i][j] !=0; j+=2) {
			pt[j/2].x = int(double(nav[i][j]) * iw / 20.0) + x + 2;
			pt[j/2].y = int(double(nav[i][j+1]) * iw / 20.0) + r.top + 2;
		}
		VERIFY(rgn.CreatePolygonRgn(pt, j/2, WINDING));
		dc.FillRgn(&rgn, &brush);
		rgn.DeleteObject();
		x += w;
	}
	dc.SelectObject(pOldPen);

	r.top = r.top + w;
	r.DeflateRect(2, 2);
	r.bottom = m_rectHeader.bottom;
	m_rectZoom = r;

	XTPPaintManager()->GradientFill(&dc, &r, RGB(100,50,50), RGB(0,0,0), FALSE);
	s.Format("Zoom %.0f:1", m_fZoomFactor);
	dc.DrawText(s, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

	dc.SelectObject(pOldFont);
//.........这里部分代码省略.........
开发者ID:tlogger,项目名称:TMon,代码行数:101,代码来源:LogGraph.cpp

示例8: OnPaint

BOOL CContainer::OnPaint(HDC hDC) 
{
	CRect rcClient;
	CPaintDC dc(GetSafeHwnd()); // device context for painting
	CBrush cbr;
	CRect m_rectDraw;
	cbr.CreateSolidBrush(CDrawLayer::GetRGBColorFace());
	GetClientRect(rcClient);
	CGDI		MemDC;
	CBitmap		m_BitmapMemDC;
	MemDC.CreateCompatibleDC(dc.m_hDC);
	m_BitmapMemDC.CreateCompatibleBitmap(dc.m_hDC,rcClient.Width(),rcClient.Height());	
	
	CBitmap *m_bitmapOld=new CBitmap(MemDC.SelectObject(&m_BitmapMemDC));
	MemDC.FillRect(&rcClient,&cbr);
		
	m_rectTab=m_rectCliente;
	m_rectDraw=m_rectCliente;
	if (m_alnTab==ALN_BOTTOM)
	{
		if (m_Numtabs > 1)
		m_rectDraw.bottom=rcClient.bottom-(m_sizeImag.cy+SPACE_TAB+2);	
	}
	else
		m_rectDraw.top=rcClient.top+(m_sizeImag.cy+SPACE_TAB+2);
	
	if (m_style != S3D) //si son carpetas estilo excel o tabbed como devstudio 7
	{
		if (m_alnTab==ALN_BOTTOM)
		{
			m_rectCliente.bottom=rcClient.bottom-(DEFAULT_FLAT);
			m_rectTab.top=rcClient.bottom+2;
		}
		else
		{
			m_rectTab.bottom=rcClient.top+(DEFAULT_FLAT)+3;
		}
	}

	int nVal=0;
	
	if (m_alnTab!=ALN_TOP)
	{
		
		MemDC.FillRect(m_rectTab,&cbr);
		CRect mrc=m_rectDraw;
		
	}
	else
	{
		CRect rc=m_rectDraw;
		for (int i=0; i< 2; i++)
		{
			MemDC.Draw3dRect(rc,CDrawLayer::GetRGBColorFace(),CDrawLayer::GetRGBColorFace());
			rc.DeflateRect(1,1);
		}
		
		rc.InflateRect(3,3);
		if (m_bDrawFrame)
			MemDC.Draw3dRect(rc,GetSysColor(COLOR_BTNSHADOW),GetSysColor(COLOR_BTNSHADOW));
		else
		{
			CRect mrc=m_rectDraw;
			mrc.top+=nVal;
			MemDC.Draw3dRect(mrc,GetSysColor(COLOR_BTNSHADOW),GetSysColor(COLOR_BTNSHADOW));

		}
		rc=m_rectDraw;
		rc.bottom=rc.top+3;
		MemDC.FillRect(rc,&cbr);
		
	}
	
	
	
	Drawtabs(&MemDC);

	dc.BitBlt(0,0,rcClient.Width(),rcClient.Height(),MemDC.m_hDC,
		      rcClient.left,rcClient.top,SRCCOPY);
	MemDC.SelectObject(m_bitmapOld);
	m_BitmapMemDC.DeleteObject();
	MemDC.DeleteDC();
	cbr.DeleteObject();
	m_bitmapOld->DeleteObject();
	dc.DeleteDC();
	delete m_bitmapOld;
	return TRUE;
}
开发者ID:axxapp,项目名称:winxgui,代码行数:88,代码来源:CContainer.cpp

示例9: DrawGripper

void CContainer::DrawGripper(CGDI* dc,CRect rcWin)
{

	CRect rc=rcWin;
	rc.bottom=rc.top+18;
	
	CBrush cb;
	cb.CreateSolidBrush(CDrawLayer::GetRGBPressBXP());
	dc->FillRect(rc, &cb);
	cb.DeleteObject ();
	dc->Draw3dRect(rc,CDrawLayer::GetRGBMenu(),CDrawLayer::GetRGBMenu());
	//CGradient M(CSize(rc.Width(),rc.Height()+4));	
	//M.PrepareVertical(dc);
	//M.Draw(dc,rc.left,rc.top+1,0,0,rc.Width(),rc.Height()+4,SRCCOPY);

	int OldMode=dc->SetBkMode(TRANSPARENT);
	CFont cf;
	
	COLORREF clrtext;
	clrtext=dc->SetTextColor(::GetSysColor (COLOR_MENUTEXT));	
	cf.CreateFont(-11,2,0,0,FW_NORMAL,0,0,0,0,1,2,1,34,"MS Sans Serif");
	
	HFONT cff=dc->SelectObject(cf);	
	
	//guardar espacio para la imagen
	
	CTab* ct=(CTab*) m_pArray[m_iSelectTab];
	
	TCHAR m_cadBreak[126];
	memset(m_cadBreak,0x00,126);
	lstrcpy(m_cadBreak,ct->lpMsg);
	int contt;
	int cont =contt=strlen(m_cadBreak);
	CSize coor=dc->GetTextExtent(m_cadBreak,cont);
	rc.left+=3;
	if ( coor.cx > (rc.Width()-35))
	{
		rc.left+=1;
		while(cont > 1 )
		{
			TCHAR m_scadtemp[64];
			memset(m_scadtemp,0x00,64);
			lstrcpy(m_scadtemp,m_cadBreak);
			lstrcat(m_scadtemp,_T("..."));
			CSize coor=dc->GetTextExtent(m_scadtemp,lstrlen(m_scadtemp));
			if(coor.cx > (rc.Width()-35))
				*(m_cadBreak+cont)=NULL;
			else
				break;
			cont--;
		}
		lstrcat(m_cadBreak,_T("..."));
		rc.right+=3;

		
			dc->DrawText(m_cadBreak,rc,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
	}
	else
			dc->DrawText(ct->lpMsg,rc,DT_SINGLELINE|DT_LEFT|DT_VCENTER);

	//-------------------------
	//No Client Button
	//-------------------------
	rc=rcWin;
	rc.left=rcWin.right-18;
	rc.bottom=rc.top+18;
	rc.right-=7;
	rc.top+=3;
	rc.bottom-=3;
	if (m_DOCKFLOAT !=BS_FLOATING)
	{
		m_rcAutoHideBtn=rc;
		m_rcAutoHideBtn.right-=12;
		m_rcAutoHideBtn.left-=12;
	}
	m_rcCloseBtn=rc;

	if (m_bCaption)
	{
		m_CloseBtn.Paint(dc,m_stateBtn,m_rcCloseBtn,CDrawLayer::GetRGBPressBXP(),TRUE );
		//if (m_DOCKFLOAT !=BS_FLOATING)
		//	m_AutoHideBtn.Paint(dc,m_stateAHBtn,m_rcAutoHideBtn,CDrawLayer::GetRGBGray(),TRUE);
	}
	
    
	dc->SelectObject(cff);	
	cf.DeleteObject();
	
}
开发者ID:axxapp,项目名称:winxgui,代码行数:89,代码来源:CContainer.cpp

示例10: OnEraseBkgnd

BOOL CFavUrlMenuDlg::OnEraseBkgnd(CDC* pDC)
{
	CRect rctWnd;
	GetWindowRect(&rctWnd);
	ScreenToClient(rctWnd);
	
	CBrush brush;
	brush.CreateSolidBrush(m_rgbBackGnd);
	CBrush *pOldBrush = pDC->SelectObject(&brush);

	CPen pen;
	pen.CreatePen(PS_SOLID, m_nBorderWidth, m_rgbBorder);
	CPen *pOldPen = pDC->SelectObject(&pen);

	// 画圆角矩形
	rctWnd.left += m_nBorderWidth/2;
	rctWnd.top += m_nBorderWidth/2;
	rctWnd.right -= m_nBorderWidth/2;
	rctWnd.bottom -= m_nBorderWidth/2;

	if ((m_nBorderWidth % 2) )
	{
		rctWnd.right -= 1;
		rctWnd.bottom -= 1;
	}
	pDC->RoundRect(rctWnd, CPoint(m_nBorderWidth, m_nBorderWidth));
	pDC->SelectObject(pOldPen);
	pen.DeleteObject();
	pDC->SelectObject(pOldBrush);
	brush.DeleteObject();

	pDC->SelectObject(m_font);
	pDC->SetTextColor(m_rgbText);
	pDC->SetBkMode(TRANSPARENT);
	CRect rctItem( m_rctFirsItem);
	rctItem.left += m_nSpacingHeigth;
	for (INT_PTR i=0; i<m_arrItems.GetSize(); i++)
	{
		ITEM item = m_arrItems.GetAt(i);
		if (item.type != ITEM_TYPE_SEPARATOR)
		{
			pDC->DrawText(item.strName, rctItem, DT_VCENTER|DT_SINGLELINE);
			if (item.type == ITEM_TYPE_DIRECTORY)
			{	// 画小三角
				int y = rctItem.top + rctItem.Height()/2;
				int x = rctItem.right - m_nSpacingHeigth;
				CPoint ptA(x, y);
				
				y = y - rctItem.Height()/2 + m_nSpacingHeigth/2;
				x -= rctItem.Height()/2;
				CPoint ptB(x, y);
				CPoint ptC(x, y+rctItem.Height() - m_nSpacingHeigth);

				CBrush brush;
				brush.CreateSolidBrush(m_rgbBorder);
				CBrush* pOld = pDC->SelectObject(&brush);
				pDC->BeginPath();
				pDC->MoveTo(ptA.x,ptA.y);
				pDC->LineTo(ptB.x,ptB.y);
				pDC->LineTo(ptC.x,ptC.y);
				pDC->LineTo(ptA.x,ptA.y);
				pDC->EndPath();
				pDC->FillPath();
				pDC->SelectObject(&pOld);
				brush.DeleteObject();
			}
		}
		else
		{
			CPen pen;
			pen.CreatePen(PS_SOLID, 1, m_rgbBorder);
			CPen *pOld = pDC->SelectObject(&pen);

			int y = rctItem.top + rctItem.Height()/5;
			int x = rctItem.left;
			rctItem.top += rctItem.Height()/5;
			rctItem.top -= rctItem.Height();
			LineAtoB(pDC, CPoint(x,y), CPoint(x+rctItem.Width()-m_nSpacingHeigth, y));

			pDC->SelectObject(pOld);
			pen.DeleteObject();
		}
		rctItem.top += m_rctFirsItem.Height();
		rctItem.bottom = rctItem.top + m_rctFirsItem.Height();
	}
	pDC->SelectObject(pOldPen);
	pen.DeleteObject();
	return TRUE;
}
开发者ID:linjianbjfu,项目名称:PlayBox,代码行数:89,代码来源:FavUrlMenuDlg.cpp

示例11: DrawShape

void CWindowsMetaFileControl::DrawShape(CDC* pDC,
													 int nShape,
													 CRect* pcrBounds,
													 COLORREF clColor,
													 COLORREF clStrokeColor /*=COLORREF(-1)*/,
													 int nStrokeWidth /*=0*/)
{
	CBrush cbColor;
	CPen cpColor;

	pDC->SaveDC();

	if (clStrokeColor == COLORREF(-1))
	{
		clStrokeColor = clColor;
	}

	TRY
	{
		int nWidth = pcrBounds->Width();
		int nHeight = pcrBounds->Height();

		if ((nWidth > 0) && (nHeight > 0))
		{
			if (cbColor.CreateSolidBrush(clColor))
			{
				if (cpColor.CreatePen(PS_INSIDEFRAME, nStrokeWidth, clStrokeColor))
				{
					pDC->SelectObject(&cbColor);
					pDC->SelectObject(&cpColor);

					if (nShape == SHAPE_CIRCLE)
					{
						pDC->Ellipse(pcrBounds);
					}
					else if (nShape == SHAPE_SQUARE)
					{
						pDC->Rectangle(pcrBounds);
					}
					else
					{
						int x0, y0;
						int x1, y1;
						int x2, y2;

						switch (nShape)
						{
							case SHAPE_TRIANGLEUP:
							{
								x0 = pcrBounds->left;
								x1 = pcrBounds->right-1;
								x2 = (x0+x1)/2;

								y0 = pcrBounds->bottom-1;
								y1 = y0;
								y2 = pcrBounds->top;

								if ((nWidth%2) == 0)
								{
									x1--;
								}

								break;
							}

							case SHAPE_TRIANGLEDOWN:
							{
								x0 = pcrBounds->left;
								x1 = pcrBounds->right-1;
								x2 = (x0+x1)/2;

								y0 = pcrBounds->top;
								y1 = y0;
								y2 = pcrBounds->bottom-1;

								if ((nWidth%2) == 0)
								{
									x1--;
								}

								break;
							}

							case SHAPE_TRIANGLELEFT:
							{
								x0 = pcrBounds->right-1;
								x1 = x0;
								x2 = pcrBounds->left;

								y0 = pcrBounds->top;
								y1 = pcrBounds->bottom-1;
								y2 = (y0+y1)/2;

								if ((nHeight%2) == 0)
								{
									y1--;
								}

								break;
							}
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例12: OnLButtonDown

void CCheckerCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	SetFocus();

	DWORD dwPos = GetMessagePos();
	CPoint clickedPoint((int)(short)LOWORD(dwPos), (int)(short)HIWORD(dwPos));
	ScreenToClient(&clickedPoint);
	
	{
		CRect cRect;
		GetWindowRect(&cRect);
		ScreenToClient(&cRect);

		UINT nY = UINT(((float)clickedPoint.y / (float(cRect.Height())/float(m_nBlocksPerColumn)))+.3);

		UINT nX = UINT(((float)clickedPoint.x / (float(cRect.Width())/float(m_nBlocksPerRow)))+.3);

		UINT nIndex = nY * m_nBlocksPerRow + nX + m_nyPos * m_nBlocksPerRow;

		if(nIndex < m_nNumberofBlocks && nX < m_nBlocksPerRow)
		{

			CString strNumber;
//			strNumber.Format("%d", nIndex + m_nStartIndex+1);
			strNumber = (m_crText.GetAt(nIndex + m_nStartIndex));

			if (strNumber.GetLength())
			{
				SetCapture();
				CreateSafeTooltipRect(clickedPoint.x, clickedPoint.y, strNumber);

				GetParent()->PostMessage(9876,(WPARAM)(nIndex+m_nStartIndex+1), 0);
			
				CClientDC dc(this);
				CBrush brush;
				brush.CreateSolidBrush(GetSysColor(COLOR_INFOBK));
				dc.Rectangle(tooltipRect);
				
				tooltipRect.left++;
				tooltipRect.top++;
				tooltipRect.bottom--;
				tooltipRect.right--;
				
				dc.FillRect(tooltipRect, &brush);
				
				CFont font;
				LOGFONT logFont;
				strcpy(logFont.lfFaceName, "Verdana");
				logFont.lfHeight = -MulDiv(12, GetDeviceCaps(dc.m_hDC, LOGPIXELSY), 72);
				logFont.lfWidth = 0;
				logFont.lfEscapement = 0;
				logFont.lfItalic = FALSE;
				logFont.lfStrikeOut = FALSE;
				logFont.lfUnderline = FALSE;
				logFont.lfWeight = FW_BOLD;
				
				font.CreateFontIndirect(&logFont);
				
				dc.SelectObject(font);
				
				dc.SetTextColor(GetSysColor(COLOR_INFOTEXT));
				dc.SetBkColor(GetSysColor(COLOR_INFOBK));
				dc.DrawText(strNumber, tooltipRect, DT_VCENTER | DT_CENTER | DT_SINGLELINE);
				
				tooltipRect.left--;
				tooltipRect.top--;
				tooltipRect.bottom++;
				tooltipRect.right++;

				m_bShouldUpdated = TRUE;
			}
		}
	}

	CWnd::OnLButtonDown(nFlags, point);
}
开发者ID:hnordquist,项目名称:MIC,代码行数:77,代码来源:CheckerCtrl.cpp

示例13: OnPaint

void CDockButton::OnPaint()
{
    CPaintDC dc(this); // device context for painting
    CBrush cb;
    COLORREF m_clrBorder=GuiDrawLayer::GetRGBColorShadow(GuiDrawLayer::m_Style);
    COLORREF m_clrFace=GuiDrawLayer::GetRGBColorFace(GuiDrawLayer::m_Style);
    CPen cp(PS_SOLID,1,m_clrFace);
    CPen* cpold=dc.SelectObject(&cp);
    CRect m_rect;
    GetClientRect(m_rect);
    cb.CreateSolidBrush(m_clrFace);
    if (GuiDrawLayer::m_Style== GUISTYLE_XP)
        dc.FillRect(m_rect,&cb);
    else
    {
        CGradient M(CSize(m_rect.Width(),m_rect.Height()));
        if (m_nDockBarAling ==AFX_IDW_DOCKBAR_LEFT || m_nDockBarAling ==AFX_IDW_DOCKBAR_RIGHT)
            M.PrepareCaptionVert(&dc,GuiDrawLayer::m_Style);
        else
            M.PrepareCaption(&dc,GuiDrawLayer::m_Style);
        M.Draw(&dc,m_rect.left,m_rect.top,0,0,m_rect.Width(),m_rect.Height(),SRCCOPY);
    }

    dc.Draw3dRect(m_rect,m_clrBorder,m_clrBorder);
    GuiDrawLayer::DrawIcon(&dc,CPoint(m_rect.left+2,m_rect.top+2),m_szBtn,m_hIcon);

    switch(m_nDockBarAling)
    {


    case AFX_IDW_DOCKBAR_TOP:
        dc.MoveTo(m_rect.left,m_rect.top);
        dc.LineTo(m_rect.right,m_rect.top);
        if(m_hIcon != NULL)
            m_rect.left+=m_szBtn.cx+4;
        DrawTextHorz(&dc,m_rect);
        break;
    case AFX_IDW_DOCKBAR_LEFT:
        dc.MoveTo(m_rect.left,m_rect.top);
        dc.LineTo(m_rect.left,m_rect.bottom);
        if(m_hIcon != NULL)
            m_rect.top+=m_szBtn.cy+4;
        DrawTextVert(&dc,m_rect);
        break;
    case AFX_IDW_DOCKBAR_RIGHT:
        dc.MoveTo(m_rect.right-1,m_rect.top);
        dc.LineTo(m_rect.right-1,m_rect.bottom);
        if(m_hIcon != NULL)
            m_rect.top+=m_szBtn.cy+4;
        DrawTextVert(&dc,m_rect);
        break;
    case AFX_IDW_DOCKBAR_BOTTOM:
        dc.MoveTo(m_rect.left,m_rect.bottom-1);
        dc.LineTo(m_rect.right,m_rect.bottom-1);
        if(m_hIcon != NULL)
            m_rect.left+=m_szBtn.cx+4;
        DrawTextHorz(&dc,m_rect);
        break;
    }
    dc.SelectObject(cpold);

}
开发者ID:ZhaoboMeng,项目名称:k-line-print,代码行数:62,代码来源:GuiDockToolBarEx.cpp

示例14: OnDraw

void CDiceView::OnDraw(CDC* pDC)
{
	CDiceDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here

	//initialize
	CRect viewRect;
	CWnd::GetClientRect(&viewRect);
	
	cellx = viewRect.right/(6+1);
	celly = viewRect.bottom/(5+1);
	radius = celly/3;


	//draw vs
	CRect vsRect;
	vsRect.left = viewRect.right/2 - radius*2;
	vsRect.top = 0;
	vsRect.right = viewRect.right/2 + radius*2;
	vsRect.bottom = celly;
	pDC->DrawText("VS", vsRect, DT_VCENTER|DT_CENTER|DT_SINGLELINE);

	//draw fight info
	for(int j = 0; j<2; j++)
	{
		if(ftInfo[j].country < 0)
			break;
		ftInfo[j].fightRect.left = (j+3)*cellx;
		ftInfo[j].fightRect.top = celly/4;
		ftInfo[j].fightRect.right = (j+3)*cellx + radius;
		ftInfo[j].fightRect.bottom = celly/4 + radius;

		CBrush brush;

		switch(ftInfo[j].country)
		{
			case 0:
				brush.CreateSolidBrush(RGB(128,128,128));
				pDC->SetBkColor(RGB(128,128,128));
				break;
            case 1:
				brush.CreateSolidBrush(RGB(255,0,0));
				pDC->SetBkColor(RGB(255,0,0));
				break;
			case 2:
				brush.CreateSolidBrush(RGB(0,255,0));
				pDC->SetBkColor(RGB(0,255,0));
				break;
			case 3:
				brush.CreateSolidBrush(RGB(0,0,255));
				pDC->SetBkColor(RGB(0,0,255));
				break;
			case 4:
				brush.CreateSolidBrush(RGB(255,255,0));
				pDC->SetBkColor(RGB(255,255,0));
				break;
			case 5:
				brush.CreateSolidBrush(RGB(255,0,255));
				pDC->SetBkColor(RGB(255,0,255));
				break;
			case 6:
				brush.CreateSolidBrush(RGB(0,255,255));
				pDC->SetBkColor(RGB(0,255,255));
				break;
			case 7:
				brush.CreateSolidBrush(RGB(0,128,128));
				pDC->SetBkColor(RGB(0,128,128));
				break;
			default:break;

		}

		pDC->FillRect(ftInfo[j].fightRect,&brush);

		char text[1] = {0};
		pDC->SetTextColor(RGB(255,255,255));
		itoa(ftInfo[j].fightPts,text,10);

		pDC->DrawText(text,ftInfo[j].fightRect,DT_VCENTER|DT_CENTER|DT_SINGLELINE);
	}

	//draw button
	buttonRect.left = viewRect.right-100;
	buttonRect.top = viewRect.bottom-50;
	buttonRect.right = viewRect.right-5;
	buttonRect.bottom = viewRect.bottom-5;
	
	CBrush brush;	
	brush.CreateSolidBrush(RGB(160,160,160));
	pDC->FillRect(buttonRect,&brush);
	pDC->SetBkColor(RGB(160,160,160));

	if(btnClicked)
		pDC->DrawEdge(buttonRect,EDGE_SUNKEN,BF_BOTTOMRIGHT | BF_TOPLEFT); 
	else
		pDC->DrawEdge(buttonRect,EDGE_RAISED,BF_BOTTOMRIGHT | BF_TOPLEFT);

	pDC->DrawText("End Turn",buttonRect,DT_VCENTER|DT_CENTER|DT_SINGLELINE);
	
//.........这里部分代码省略.........
开发者ID:wufan0920,项目名称:dice-war,代码行数:101,代码来源:DiceView.cpp

示例15: DrawItem

void CButtonST::DrawItem(UINT ctrlID, LPDRAWITEMSTRUCT lpDIS)
{
	CDCHandle pDC = lpDIS->hDC;

	CPenHandle	pOldPen;

	// Checkbox or Radiobutton style ?
	if (m_bIsCheckBox)
		{
		m_bIsPressed  =  (lpDIS->itemState & ODS_SELECTED) || m_nCheck;
		}
	// Normal button OR other button style ...
	else
		{
		m_bIsPressed = (lpDIS->itemState & ODS_SELECTED);
		}

	m_bIsFocused  = (lpDIS->itemState & ODS_FOCUS) != 0;
	m_bIsDisabled = (lpDIS->itemState & ODS_DISABLED) != 0;
	
	CRect itemRect = lpDIS->rcItem;

	pDC.SetBkMode(TRANSPARENT);

	if (!m_bIsFlat)
		{
		if (m_bIsFocused || GetDefault())
			{
			CBrush br;
			br.CreateSolidBrush(RGB(0,0,0));  
			pDC.FrameRect(&itemRect, br);
			itemRect.DeflateRect(1, 1);
			}
		}

	// Prepare draw... paint button background

	// Draw transparent?
	if (m_bDrawTransparent)
		{
		PaintBk(pDC);
		}
	else
		{
		OnDrawBackground(pDC, &itemRect);
		}

	// Draw pressed button
	if (m_bIsPressed)
		{
		if (m_bIsFlat)
			{
			if (m_bDrawBorder)
				{
				OnDrawBorder(pDC, &itemRect);
				}
			}
		else    
			{
			CBrush brBtnShadow;
			brBtnShadow.CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW));
			pDC.FrameRect(&itemRect, brBtnShadow);
			}
		}
	else // ...else draw non pressed button
		{
		CPen penBtnHiLight; // White
		CPen pen3DLight;       // Light gray
		CPen penBtnShadow;   // Dark gray
		CPen pen3DDKShadow; // Black

		penBtnHiLight.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNHILIGHT)); // White
		pen3DLight.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_3DLIGHT));       // Light gray
		penBtnShadow.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_BTNSHADOW));   // Dark gray
		pen3DDKShadow.CreatePen(PS_SOLID, 0, ::GetSysColor(COLOR_3DDKSHADOW)); // Black

		if (m_bIsFlat)
			{
			if (m_bMouseOnButton && m_bDrawBorder)
				{
				pDC.Draw3dRect(itemRect, ::GetSysColor(COLOR_BTNHILIGHT), ::GetSysColor(COLOR_BTNSHADOW));
				}
			}
		else
			{
			// Draw top-left borders
			// White line
			pOldPen = pDC.SelectPen(penBtnHiLight);
			pDC.MoveTo(itemRect.left, itemRect.bottom-1);
			pDC.LineTo(itemRect.left, itemRect.top);
			pDC.LineTo(itemRect.right, itemRect.top);
			// Light gray line
			pDC.SelectPen(pen3DLight);
			pDC.MoveTo(itemRect.left+1, itemRect.bottom-1);
			pDC.LineTo(itemRect.left+1, itemRect.top+1);
			pDC.LineTo(itemRect.right, itemRect.top+1);
			// Draw bottom-right borders
			// Black line
			pDC.SelectPen(pen3DDKShadow);
			pDC.MoveTo(itemRect.left, itemRect.bottom-1);
//.........这里部分代码省略.........
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:101,代码来源:ButtonST.cpp


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