void CSet::DrawDialog() { CDC *pDC=GetWindowDC(); CBrush brush; CRect winRect; GetWindowRect(&winRect); CRect rect; //底线 rect.left =0; rect.right =winRect.Width (); rect.top =winRect.Height ()-1; rect.bottom =winRect.Height (); brush.CreateSolidBrush (RGB(94,179,227)); pDC->FillRect (&rect,&brush); brush.DeleteObject (); //上线 rect.left =0; rect.right =winRect.Width (); rect.top =0; rect.bottom =1; brush.CreateSolidBrush (RGB(94,179,227)); pDC->FillRect (&rect,&brush); brush.DeleteObject (); //left线 rect.left =0; rect.right =1; rect.top =0; rect.bottom =winRect.Height (); brush.CreateSolidBrush (RGB(94,179,227)); pDC->FillRect (&rect,&brush); brush.DeleteObject (); //right线 rect.left =winRect.Width ()-1; rect.right =winRect.Width(), rect.top =0; rect.bottom =winRect.Height (); brush.CreateSolidBrush (RGB(94,179,227)); pDC->FillRect (&rect,&brush); pDC->DeleteDC (); brush.DeleteObject (); }
void CrainDlg::doThread()//由线程执行的方法 { CBrush aBrush;//画笔,主要用来填充颜色 CPen aPen;//钢笔,主要用来画线条 CRect aRect;//矩形, CWnd * pWind=GetDlgItem(IDC_PIC);//获取画图框资源 CDC* pDC=pWind->GetDC();//画布 struct dropletchain *pRain;//用来读取雨点链表 while(1) { //画背景 aBrush.CreateSolidBrush(RGB(0,0,0));//设置画笔的颜色,即天空的颜色 pWind->GetClientRect(&aRect);//获取画布大小 aRect.bottom-=DEFAULT_BOTTOM_HEIGHT;//修改底部的高度,底部向上为天空 pDC->FillRect(aRect,&aBrush);//绘制上方天空 aBrush.DeleteObject();//用完画笔删除 aBrush.CreateSolidBrush(RGB(9,128,104));//设置池塘的颜色 aRect.top+=aRect.Height();//顶部下移 aRect.bottom+=DEFAULT_BOTTOM_HEIGHT;//底部高度下移 pDC->FillRect(aRect,&aBrush);//绘制下方池塘 aBrush.DeleteObject();//删除画笔 pDC->SelectStockObject(NULL_BRUSH);//把DC设置成空心画笔,在画涟漪时可以画出空心椭圆 pRain=pDropletchain;//把指针移向链表头 while(pRain) { aPen.CreatePen(PS_SOLID,pRain->data->thick,pRain->data->color);//创建钢笔 pDC->SelectObject(&aPen);//用这个钢笔来画画 if(pRain->data->y>aRect.top)//若雨点到达池塘顶部 { //画涟漪 pDC->Ellipse(pRain->data->x-pRain->data->radius-ELLIPSE,pRain->data->y-pRain->data->radius,pRain->data->x+pRain->data->radius+ELLIPSE,pRain->data->y+pRain->data->radius);//画出椭圆 pRain->data->radius++;//涟漪椭圆半径增大 if(pRain->data->radius>pRain->data->len||pRain->data->x+pRain->data->radius+ELLIPSE>=aRect.Width()) initDroplet(pRain->data);//如果雨点半径大于雨点长度则重新生成雨点 } else { //画雨点 pDC->MoveTo(pRain->data->x,pRain->data->y);//把画笔移动到指定的坐标 pDC->LineTo(pRain->data->x+(int)pRain->data->len*sin(pRain->data->angle),pRain->data->y+(int)pRain->data->len*cos(pRain->data->angle));//根据角度和长度绘制出斜线 pRain->data->x+=pRain->data->speed;pRain->data->y+=pRain->data->speed;//雨点的坐标增大,增大幅度为各自的speed if(pRain->data->x+(int)pRain->data->len*sin(pRain->data->angle)>=aRect.Width()-pRain->data->thick) initDroplet(pRain->data);//如果超出右侧界限则重新生成雨点 } aPen.DeleteObject();//删除钢笔 pRain=pRain->next;// } Sleep(100-m_slider.GetPos());//在死循环中休眠线程,形成动画效果 } pDC->ReleaseOutputDC();//释放DC资源 }
void CGradientProgressCtrl::DrawGradient(CPaintDC *pDC, const RECT &rectClient, const int &nMaxWidth) { RECT rectFill; //显示区域 float fStep; //每一步的幅宽 CBrush brush; //显示的颜色画刷 CMemDC1 memDC(pDC); int r,g,b; float rStep,gStep,bStep; //得到不同颜色并相减,返回颜色之间的最大差值 r=(GetRValue(m_clrEnd)-GetRValue(m_clrStart)); g=(GetGValue(m_clrEnd)-GetGValue(m_clrStart)); b=(GetBValue(m_clrEnd)-GetBValue(m_clrStart)); //使进程条显示的总数 等于最大的颜色差值 int nSteps=max(abs(r),max(abs(g),abs(b))); //确定每一颜色填充多大的矩形区域 fStep=(float)rectClient.right/(float)nSteps; //设置每一颜色填充的步数 rStep=r/(float)nSteps; gStep=g/(float)nSteps; bStep=b/(float)nSteps; r=GetRValue(m_clrStart); g=GetGValue(m_clrStart); b=GetBValue(m_clrStart); //绘制颜色渐变的进程条 for(int iOnBand=0;iOnBand<nSteps;iOnBand++) { ::SetRect(&rectFill, //以下为填充矩形区域的左上角x,y和右下角x,y (int)(iOnBand*fStep), 0, (int)((iOnBand+1)*fStep), rectClient.bottom); VERIFY(brush.CreateSolidBrush(RGB(r+rStep*iOnBand,g+gStep*iOnBand,b+bStep*iOnBand))); memDC.FillRect(&rectFill,&brush); VERIFY(brush.DeleteObject()); //在结束绘制之前,使用背景色填充乘下的的客户区域 if(rectFill.right>nMaxWidth) { ::SetRect(&rectFill,rectFill.right,0,rectClient.right,rectClient.bottom); VERIFY(brush.CreateSolidBrush(m_clrBkGround)); memDC.FillRect(&rectFill,&brush); VERIFY(brush.DeleteObject()); return; } } }
/* 画棋子 */ void Chess::DrawChess(CDC *pDC) { CBrush *brush; COLORREF color; CPen pen; int a, b; a = x - SIZE / 2; b = y - SIZE / 2; /* 选择颜色 */ if (this->color == WHITE) /* 白色 */ { color = RGB(255, 255, 255); pen.CreatePen(PS_SOLID, 1, color); } else /* 黑色 */ { color = RGB(0, 0, 0); pen.CreatePen(PS_SOLID, 1, color); } brush = new CBrush(color); /* 笔的属性 */ pDC->SelectObject(brush); /* 使用这支笔 */ pDC->SelectObject(&pen); pDC->Ellipse(a, b, a + size, b + size); /* 画圆 */ brush->DeleteObject(); pen.DeleteObject(); }
void CChildView::OnPaint() { CPaintDC dc(this); // device context for painting CPen Pen; Pen.CreatePen(PS_SOLID, 1, RGB(0,0,255)); CPen *pOldPen; pOldPen = dc.SelectObject(&Pen); CBrush Brush; Brush.CreateSolidBrush(RGB(0,255,0)); CBrush *pOldBrush = dc.SelectObject(&Brush); { dc.MoveTo(0,0); dc.LineTo(100,100); dc.Rectangle(100,100,200,200); } dc.SelectObject(pOldPen); dc.SelectObject(pOldBrush); Brush.DeleteObject(); Pen.DeleteObject(); if(dibData == NULL) return; SetDIBitsToDevice(dc.m_hDC, 0, 0, imageWidth, imageHeight, 0, 0, 0, imageHeight, dstData, bitmapInfo, DIB_RGB_COLORS); }
void Process::MakeBitMap() { CClientDC ClientDC(pDCShow->GetWindow()); if(m_pResMap!=NULL) delete m_pResMap; m_pResMap=new CBitmap(); m_pResMap->CreateCompatibleBitmap(&ClientDC,m_nWndWidth,m_nWndHeight); CDC dc; dc.CreateCompatibleDC(&ClientDC); dc.SelectObject(m_pResMap); for(int i=0; i<m_nWndHeight; i++) for(int j=0; j<m_nWndWidth; j++) dc.SetPixelV(j,i,RGB(m_tResPixelArray[i][j].rgbRed,m_tResPixelArray[i][j].rgbGreen,m_tResPixelArray[i][j].rgbBlue)); if(m_bFaceOK && m_bShowFace) { CBrush Pen; Pen.CreateSolidBrush(RGB(255,0,0)); dc.FrameRect(m_rFaceRegion,&Pen); Pen.DeleteObject(); } dc.DeleteDC(); MyDraw(); }
void CEZSnakeCtrl::OnPaint() { PROC_TRACE; CPaintDC dc(this); CDC *pdc; pdc = &dc; CRect rect,rcLeft,rcRight,rcSnake; GetClientRect(&rect); rcLeft.CopyRect(&rect); rcRight.CopyRect(&rect); rcSnake.CopyRect(&rect); float nTailpos=(float)m_nTail/(float)m_nMax*(float)rect.right; float nHeadpos=(float)m_nPos/(float)m_nMax*(float)rect.right; rcSnake.left=(long)(m_bReverse?nHeadpos:nTailpos); rcSnake.right=(long)(m_bReverse?nTailpos:nHeadpos); rcLeft.right=rcSnake.left; rcRight.left=rcSnake.right; DrawGradient(pdc,rcSnake); CBrush brush; VERIFY(brush.CreateSolidBrush(m_clrBk)); pdc->FillRect(&rcLeft, &brush); pdc->FillRect(&rcRight,&brush); VERIFY(brush.DeleteObject()); // Do not call CStatic::OnPaint() for painting messages }
void CGuiWorkTab::OnPaint() { CPaintDC dc(this); // device context for painting CBrush cbr; CRect m_rectDraw; cbr.CreateSolidBrush(GuiDrawLayer::GetRGBColorXP()); GetClientRect(m_rectCliente); m_rectTab = m_rectCliente; m_rectDraw = m_rectCliente; if (m_alnTab == ALN_BOTTOM) m_rectDraw.bottom = m_rectCliente.bottom- (m_sizeImag.cy + SPACE_TAB + 2); CRect rc = m_rectDraw; rc.top += 1; rc.bottom = rc.top + 1; dc.Draw3dRect(rc, GuiDrawLayer::GetRGBColorFace(m_StyleDisplay), GuiDrawLayer::GetRGBColorFace(m_StyleDisplay)); if (m_alnTab == ALN_BOTTOM) { m_rectCliente.bottom = m_rectCliente.bottom- (DEFAULT_FLAT); m_rectTab.top = m_rectCliente.bottom + 2; } cbr.DeleteObject(); Drawtabs(&dc); }
BOOL COptionTreeItemImage::GetBitmapFromImageList(CDC *pDC, HICON hIcon, CBitmap &bmp) { // Declare varaibles CDC dc; CBrush brush; dc.CreateCompatibleDC(pDC); bmp.CreateCompatibleBitmap(pDC, m_sImageSizes.cx, m_sImageSizes.cy); CBitmap* pOldBmp = dc.SelectObject(&bmp); brush.CreateSolidBrush(GetSysColor(COLOR_MENU)); ::DrawIconEx(dc.GetSafeHdc(), 0, 0, hIcon, m_sImageSizes.cx, m_sImageSizes.cy, 0, (HBRUSH)brush,DI_NORMAL); // Restore dc.SelectObject(pOldBmp); // Delete if (brush.GetSafeHandle() != NULL) { brush.DeleteObject(); } if (dc.GetSafeHdc() != NULL) { dc.DeleteDC(); } // The icon is not longer needed DestroyIcon(hIcon); return TRUE; }
BOOL CSplitter::OnPaint(HDC hDC) { CPaintDC dc(GetSafeHwnd()); // device context for painting CBrush cbr; CRect rcClient; GetClientRect(&rcClient); cbr.CreateSolidBrush(clrBg); 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); DrawSplitter(m_rcSpplitter,m_rectLeft,m_rectRight,&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(); dc.DeleteDC(); m_bitmapOld->DeleteObject(); delete m_bitmapOld; return TRUE; }
BOOL CWorkTab::OnPaint(HDC hDC) { CPaintDC dc(this); // device context for painting CBrush cbr; CRect m_rectDraw; cbr.CreateSolidBrush(CDrawLayer::GetRGBColorXP()); GetClientRect(m_rectCliente); m_rectTab = m_rectCliente; m_rectDraw = m_rectCliente; if (m_alnTab == ALN_BOTTOM) m_rectDraw.bottom = m_rectCliente.bottom- (theApp->m_WinMain->m_sizeImagDocks.cy + SPACE_TAB + 2); CRect rc = m_rectDraw; rc.top += 1; rc.bottom = rc.top + 1; dc.Draw3dRect(rc, CDrawLayer::GetRGBColorFace(), CDrawLayer::GetRGBColorFace()); if (m_alnTab == ALN_BOTTOM) { m_rectCliente.bottom = m_rectCliente.bottom- (DEFAULT_FLAT); m_rectTab.top = m_rectCliente.bottom + 2; } cbr.DeleteObject(); Drawtabs(&dc); dc.DeleteDC(); return TRUE; }
void CColorWnd::Init() { int x, y; float H, L; CDC dcMem; CPaintDC dc(this); CBrush brush; CRect rect; if (colorGradiant.m_hObject != NULL) colorGradiant.DeleteObject(); // get rid of old bitmap dcMem.CreateCompatibleDC(&dc); GetClientRect(clientRect); clientSize = clientRect.Size(); colorGradiant.CreateCompatibleBitmap(&dc, clientSize.cx, clientSize.cy); ASSERT(colorGradiant.m_hObject != NULL); CBitmap* pOldBitmap = dcMem.SelectObject(&colorGradiant); for (y = 0; y < clientSize.cy; y++) for (x = 0; x < clientSize.cx; x++) { H = ((float)x) * 360 / (clientSize.cx - 1); L = ((float)(clientSize.cy - 1) - y) / (clientSize.cy - 1); rect.SetRect(x, y, x + 1, y + 1); brush.CreateSolidBrush(HLS_To_RGB(H, L, 1)); dcMem.FillRect(&rect, &brush); brush.DeleteObject(); } dcMem.SelectObject(pOldBitmap); dcMem.DeleteDC(); }
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); CBrush b; if (!!m_list.GetItemState(nItem, LVIS_SELECTED)) { b.CreateSolidBrush(0xf1dacc); pDC->FillRect(rcItem, &b); b.DeleteObject(); b.CreateSolidBrush(0xc56a31); pDC->FrameRect(rcItem, &b); } else { b.CreateSysColorBrush(COLOR_WINDOW); pDC->FillRect(rcItem, &b); } CString str; pDC->SetTextColor(0); str = m_list.GetItemText(nItem, 0); pDC->TextOut(rcItem.left + 3, (rcItem.top + rcItem.bottom - pDC->GetTextExtent(str).cy) / 2, str); str = m_list.GetItemText(nItem, 1); if (!str.IsEmpty()) { pDC->TextOut(rcItem.right - pDC->GetTextExtent(str).cx - 3, (rcItem.top + rcItem.bottom - pDC->GetTextExtent(str).cy) / 2, str); } }
void DlgPalette::DrawCell(CDC *pDC, long index) { CRect rect; if (!GetCellRect(index, rect)) return; CBrush brush; if (m_editalpha){ brush.CreateSolidBrush(RGB(m_pal[index].rgbReserved, m_pal[index].rgbReserved , m_pal[index].rgbReserved )); }else{ brush.CreateSolidBrush(RGB(m_pal[index].rgbRed , m_pal[index].rgbGreen , m_pal[index].rgbBlue )); } CPen pen; if (index==m_selected) pen.CreatePen(PS_SOLID, 2, ::GetSysColor(COLOR_3DDKSHADOW)); else pen.CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW)); CBrush* pOldBrush = (CBrush*) pDC->SelectObject(&brush); CPen* pOldPen = (CPen*) pDC->SelectObject(&pen); // Draw the cell colour pDC->Rectangle(rect); // restore DC and cleanup pDC->SelectObject(pOldBrush); pDC->SelectObject(pOldPen); brush.DeleteObject(); pen.DeleteObject(); }
void SliderBoth::SetBlockColor() { #if 1 CClientDC dc(this); //CDC* pdc = this->GetDC(); //CDC*dc = this->GetDC(); CRect rc; GetClientRect(&rc); CreateCompatibleDC((HDC)&dc); int iNumTic=(pos.iMax-pos.iMin)/pos.iTick; const int iL=MARGIN_SLIDE; const int iR=rc.right-MARGIN_SLIDE; const double dbStep=(iR-iL)*1.0/iNumTic; double db=iL; CBrush brush; //brush.CreateSolidBrush(RGB(200,100,255)); brush.CreateSolidBrush(RGB(165,196,211)); //CBrush * pOldBrush= dc.SelectObject (&brush); CBrush * pOldBrush= dc.SelectObject (&brush);//LSC double lval = pos.iL*dbStep;//左边滑块 double rval = pos.iR*dbStep;//右边滑块 int iM=iNumTic/2; int RectaParam1,RectaParam2 = rc.top+1,RectaParam3,RectaParam4 = rc.bottom-MARGIN_SLIDE*2; if (pos.iL>=iM) { RectaParam1 = (int)lval;//+MARGIN_SLIDE*2; }else { RectaParam1 = (int)lval+MARGIN_SLIDE*2; } if (pos.iR <= iM) { RectaParam3 = (int)rval+12; }else { RectaParam3 = (int)rval+3; } // dc.Rectangle((int)lval+MARGIN_SLIDE*2,rc.top+1,(int)rval,rc.bottom-MARGIN_SLIDE*2); dc.Rectangle(RectaParam1,RectaParam2,RectaParam3,RectaParam4); dc.SelectObject (pOldBrush); brush.DeleteObject(); #endif }
void CGradient::PrepareVertical( CDCHandle pDC, COLORREF TopColor, COLORREF BottomColor) { UINT RTop, GTop, BTop, RBot, GBot, BBot; RTop = GetRValue(TopColor); GTop = GetGValue(TopColor); BTop = GetBValue(TopColor); RBot = GetRValue(BottomColor); GBot = GetGValue(BottomColor); BBot = GetBValue(BottomColor); if (mpMemDC != NULL) delete mpMemDC; CBitmap Bitmap; mpMemDC = new CDC; mpMemDC->CreateCompatibleDC(pDC); mpMemDC->SetMapMode(MM_TEXT); Bitmap.CreateCompatibleBitmap(pDC,mSize.cx, mSize.cy); mpMemDC->SelectBitmap(Bitmap); double rStep, gStep, bStep; double rCount, gCount, bCount; double RectHeight = mSize.cy / 256.0; const int NUM_COLORS = 256; rCount = RTop; gCount = GTop; bCount = BTop; rStep =- ((double)RTop - RBot) / NUM_COLORS; gStep =- ((double)GTop - GBot) / NUM_COLORS; bStep =- ((double)BTop - BBot) / NUM_COLORS; CBrush FillBrush; for (int ColorCount = 0; ColorCount < NUM_COLORS; ColorCount ++) { FillBrush.CreateSolidBrush(RGB(rCount, gCount, bCount)); mpMemDC->FillRect(CRect(0, (int)(ColorCount * RectHeight), mSize.cx, (int)((ColorCount + 1) * RectHeight)), FillBrush); rCount += rStep; gCount += gStep; bCount += bStep; FillBrush.DeleteObject(); } }
void CDialogWmf::OnPaint() { CPaintDC dc(this); // device context for painting CRect rect; CBrush brush; // Line color m_FrameLine.GetWindowRect(&rect); ScreenToClient(&rect); brush.CreateSolidBrush(m_ColorLine); dc.FillRect(&rect,&brush); brush.DeleteObject(); // Face color m_FrameFace.GetWindowRect(&rect); ScreenToClient(&rect); brush.CreateSolidBrush(m_ColorFace); dc.FillRect(&rect,&brush); brush.DeleteObject(); }
void CCustomHeader::OnPaint() { CPaintDC dc(this); int ItemCount = GetItemCount(); CRect cRC; GetClientRect(&cRC); CBrush brush; CBitmap bmp; bmp.LoadBitmap(IDB_LISTHEAD); brush.CreatePatternBrush(&bmp); dc.FillRect(cRC,&brush); CPen pen(PS_SOLID,1,RGB(236,233,216)); for (int i = 0 ; i <ItemCount; i++) { CRect rc; GetItemRect(i,rc); rc.DeflateRect(0,0,1,0); //绘制分隔条 dc.SelectObject(&pen); dc.MoveTo(rc.right+1,0); dc.LineTo(rc.right+1,rc.Height()); //绘制文本 char text[100]; memset(text,0,100); CListCtrl* pList = (CListCtrl*)this->GetParent(); if (pList != NULL) { LVCOLUMN col; memset(&col,0,sizeof(LVCOLUMN)); col.mask = LVCF_TEXT; col.cchTextMax = 100; col.pszText = (LPWSTR)text; pList->GetColumn(i,&col); dc.SetTextColor(RGB(0,0,0)); CFont* font = GetFont(); dc.SelectObject(font); dc.SetBkMode(TRANSPARENT); CString str ; str.Format(_T("%s"),text); dc.DrawText(str,rc,DT_CENTER |DT_VCENTER|DT_WORD_ELLIPSIS|DT_SINGLELINE); } } pen.DeleteObject(); bmp.DeleteObject(); brush.DeleteObject(); }
void CBeatDetectView::DrawTimeRuler ( CDC * pDC, LPRECT lprc ) { // Draw Background CBrush Brush; Brush.CreateSolidBrush( 0x00BBBBBB ); pDC->FillRect( lprc, &Brush ); Brush.DeleteObject(); // Draw horizontal marker lines Brush.CreateSolidBrush( 0x00000000 ); RECT rcClip; pDC->GetClipBox( &rcClip ); INT32 nStartPixel = rcClip.left; INT32 nEndPixel = rcClip.right+2; FLOAT flTicks = (FLOAT)(1/m_dZoom); INT32 nTickHeight = lprc->bottom - lprc->top - 1; while( flTicks > 25 ) { FLOAT fli = (INT32)(nStartPixel/flTicks) * flTicks; for(; fli<nEndPixel; fli+=flTicks) { RECT rcTick; rcTick.bottom = lprc->bottom; rcTick.top = rcTick.bottom - nTickHeight; rcTick.left = (LONG)fli; rcTick.right = (LONG)fli+1; pDC->FillRect( &rcTick, &Brush ); } nTickHeight = (nTickHeight * 2) / 3; flTicks /= 2; } Brush.DeleteObject(); }
void CGradientProgressCtrl::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here CRect rectClient; GetClientRect(&rectClient); // If the current positionis invalid then we should fade into the background 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; } // The actions to take depend on whether or not we are a vertical control DWORD dwStyles = GetStyle(); BOOL bVertical = (BOOL)(dwStyles & PBS_VERTICAL); // Figure out what part should be visible so we can stop the gradient when needed float maxWidth; if (bVertical) maxWidth = ((float)m_nCurrentPosition/(float)m_nUpper * (float)rectClient.bottom); else maxWidth = ((float)m_nCurrentPosition/(float)m_nUpper * (float)rectClient.right); // Draw the gradient DrawGradient(&dc, rectClient, (int)maxWidth, bVertical); // Show percent indicator if needed if (m_bShowPercent) { CString strPercent; float fp = 100.0f; fp *= (float)(m_nCurrentPosition-m_nLower); fp /= (float)(m_nUpper-m_nLower); strPercent.Format(_T("%ld/%ld"), m_nCurrentPosition, m_nUpper); dc.SetTextColor(m_clrText); dc.SetBkMode(TRANSPARENT); dc.DrawText(strPercent, &rectClient, DT_VCENTER | DT_CENTER | DT_SINGLELINE); } // Do not call CProgressCtrl::OnPaint() for painting messages }
//**************************************************************************** BOOL CContainer::OnEraseBkgnd(HDC hDC) { // TODO: Add your message handler code here and/or call default CGDI pDC(hDC); if (m_Numtabs == 0) { CBrush cbr; cbr.CreateSysColorBrush(COLOR_BTNFACE); CRect m_rect; GetClientRect(m_rect); pDC.FillRect(m_rect,&cbr); cbr.DeleteObject(); } return TRUE; }
BOOL ColorControl::OnEraseBkgnd(CDC* pDC) { int r = (color & 0x1f) << 3; int g = (color & 0x3e0) >> 2; int b = (color & 0x7c00) >> 7; CBrush br; br.CreateSolidBrush(RGB(r,g,b)); RECT rect; GetClientRect(&rect); pDC->FillRect(&rect,&br); pDC->DrawEdge(&rect, EDGE_SUNKEN, BF_RECT); br.DeleteObject(); return TRUE; }
void CPalViewDlg::OnPaint() { CPaintDC dc(this); // device context for painting int x,y; CRect Rect; CBrush Brush; for (x = 0; x < 16; x++) for (y = 0; y < 16; y++) { Rect = CRect (x*12, y*13, x*12+11, y*13+12); Rect.OffsetRect (14, 14); PLPixel32 Col = m_pPal[x*8+y]; Brush.CreateSolidBrush (RGB (Col.GetR(), Col.GetG(), Col.GetB ())); dc.FillRect (Rect, &Brush); Brush.DeleteObject(); } }
void CPanel::DrawPanel(CDC* pDC) { CBrush brush; CPen pen(PS_DOT,2,RGB(10,10,255)),GridPen(PS_SOLID,1,RGB(190,190,190)); brush.CreateSolidBrush(PanelColor); pDC->SelectObject(&pen); CBrush *pOldBrush=pDC->SelectObject(&brush); //DrawBegin RECT Rect=PanelRect; Rect.bottom=PanelRect.bottom; Rect.right=PanelRect.right; pDC->Rectangle(&Rect); pDC->Rectangle(&TextRect); //Text CString str; pDC->SetTextColor(RGB(255,0,255)); pDC->SetBkColor(PanelColor); str="姓名: " + pManager->Name; pDC->TextOut(TextRect.left+10,TextRect.top+10,str); str.Format("等级: %d",pManager->Level); pDC->TextOut(TextRect.left+10,TextRect.top+40,str); str.Format("消掉行数:%d",pManager->LineNumber); pDC->TextOut(TextRect.left+10,TextRect.top+70,str); str.Format("分值: %d",pManager->Result); pDC->TextOut(TextRect.left+10,TextRect.top+100,str); //DrawLine pDC->SelectObject(&GridPen); for(int iy=PanelRect.top;iy<PanelRect.bottom;iy+=GridSize.cy) { pDC->MoveTo(PanelRect.left,iy); pDC->LineTo(PanelRect.right,iy); } for(int ix=PanelRect.left;ix<PanelRect.right;ix+=GridSize.cx) { pDC->MoveTo(ix,PanelRect.top); pDC->LineTo(ix,PanelRect.bottom); } //DrawEnd pDC->SelectObject(pOldBrush); brush.DeleteObject(); }
void CComboBoxExt::DrawCombo(enTypeShow enShow,CGDI* pDC) { CRect m_rcClient; CRect m_rcDropDown; GetClientRect(&m_rcClient); CGradient M(CSize(m_rcClient.Width(),m_rcClient.Height())); M.PrepareVertical(pDC); M.Draw(pDC,0,0,0,0,m_rcClient.Width(),m_rcClient.Height(),SRCCOPY); m_rcClient.bottom-=2; m_rcClient.DeflateRect(1,1); if (enShow==CM_NORMAL) pDC->Draw3dRect(&m_rcClient,CDrawLayer::GetRGBColorWhite(),CDrawLayer::GetRGBColorWhite()); else // && !XP pDC->Draw3dRect(&m_rcClient,CDrawLayer::GetRGBMenu(),CDrawLayer::GetRGBMenu()); //debemos pintar el borde del boton drawDwon m_rcClient.DeflateRect(1,1); m_rcClient.left=m_rcClient.right-m_iWidthDrowDown; m_rcClient.DeflateRect(1,1); if (enShow!=CM_NORMAL) pDC->Draw3dRect(&m_rcClient,CDrawLayer::GetRGBFondoXP(),CDrawLayer::GetRGBFondoXP()); m_rcClient.InflateRect(0,1); if (enShow==CM_NORMAL) { //el boton no esta seleccionado m_rcClient.left += 2; m_rcClient.right+= 2; DrawArrow(pDC,m_rcClient); } else { m_rcClient.InflateRect(1,1); CBrush cblu; cblu.CreateSolidBrush(enShow == CM_ONFOCUS? CDrawLayer::GetRGBFondoXP():CDrawLayer::GetRGBPressBXP()); pDC->FillRect(&m_rcClient,&cblu); m_rcClient.right += 1; pDC->Draw3dRect(&m_rcClient,CDrawLayer::GetRGBMenu(),CDrawLayer::GetRGBMenu()); DrawArrow(pDC,m_rcClient); cblu.DeleteObject(); } }
long CHSDib::Draw(HDC pDC, long xoffset, long yoffset,BOOL bTracking /*= FALSE*/) { if( (hDib) && (pDC) ) { CRect rect(xoffset, yoffset, m_bi.biWidth, m_bi.biHeight); if( bTracking == 2 ) // focus { FillRect(pDC, &rect, (HBRUSH) (COLOR_INFOBK + 1)); } else if( bTracking == 1) // over { FillRect(pDC, &rect, (HBRUSH) (COLOR_WINDOW + 1)); } else { FillRect(pDC, &rect, (HBRUSH) (COLOR_BTNFACE + 1)); } CBrush hBrush; hBrush.CreateSolidBrush(0); FrameRect(pDC, &rect, (HBRUSH) hBrush ); hBrush.DeleteObject(); //LPSTR lpDIB = (char*)hDib; //set image to hdc... //SetStretchBltMode(pDC,MAXSTRETCHBLTMODE);//COLORONCOLOR); //SetDIBitsToDevice(pDC, xoffset, yoffset, // m_bi.biWidth, m_bi.biHeight, 0, 0, 0, // m_bi.biHeight, GetBits(), // (BITMAPINFO*)lpDIB, DIB_RGB_COLORS); #if Support_CHSDib //palette must be correctly filled LPSTR lpDIB = (char*)hDib; //set image to hdc... SetStretchBltMode(pDC,MAXSTRETCHBLTMODE);//COLORONCOLOR); SetDIBitsToDevice(pDC, xoffset, yoffset, m_bi.biWidth, m_bi.biHeight, 0, 0, 0, m_bi.biHeight, GetBits(), (BITMAPINFO*)lpDIB, DIB_RGB_COLORS); #endif return 1; } return 0; }
void CDlgVideo::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here // Do not call CDialogEx::OnPaint() for painting messages CBrush brushBkgnd; CRect rcClient; brushBkgnd.CreateSolidBrush(RGB(0, 0, 0)); GetClientRect(&rcClient); dc.FillRect(&rcClient, &brushBkgnd); brushBkgnd.DeleteObject(); //释放画刷 if ( m_pEasyLogo != NULL && !m_pEasyLogo->IsNull() ) { int nStartX = (rcClient.Width()-184)/2; int nStartY = (rcClient.Height()-184)/2; m_pEasyLogo->DrawImage(CDC::FromHandle(dc.m_hDC),nStartX,nStartY); } }
void CMainFrame::UpdateEventsStatus() { CString status; CDC* pDC = m_wndStatusBar.GetDC(); CBrush* pBrush; if (m_pDoc->HasBadEventRecently() == true) { pBrush = new CBrush(&m_bitmapEventStatusBad); status = "\r\tStreaming Problem. Click Here for more info"; m_wndStatusBar.SetPaneInfo(0,ID_INDICATOR_EVENTS,SBPS_NORMAL,280); } else { pBrush = new CBrush(&m_bitmapEventStatusOK); status = "\r\tOK"; m_wndStatusBar.SetPaneInfo(0,ID_INDICATOR_EVENTS,SBPS_NORMAL,60); } m_wndStatusBar.SetPaneText(0, status ); RECT rect; rect.left = sk_statusbarIconOffsetX; rect.right = sk_statusbarIconOffsetX + 15; rect.top = sk_statusbarIconOffsetY; rect.bottom = sk_statusbarIconOffsetY + 15; if(m_pDoc->HasBadEventRecently() == true) { switch (m_WarningShown) { case true: m_WarningShown = false; break; case false: pBrush = new CBrush(RGB(212,208,200)); m_wndStatusBar.SetPaneText(0, ""); m_WarningShown = true; break; } } pDC->FillRect(&rect,pBrush); ReleaseDC(pDC); pBrush->DeleteObject(); delete pBrush; }
void CDlgRender::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: 在此处添加消息处理程序代码 // 不为绘图消息调用 CDialogEx::OnPaint() CBrush brushBkgnd; CRect rcClient; brushBkgnd.CreateSolidBrush(RGB(0, 0, 0)); GetClientRect(&rcClient); dc.FillRect(&rcClient, &brushBkgnd); brushBkgnd.DeleteObject(); //释放画刷 CDC* pDC = CDC::FromHandle(dc.m_hDC); if ( m_pEasyLogo != NULL && !m_pEasyLogo->IsNull() ) { int nStartX = (rcClient.Width()-184)/2; int nStartY = (rcClient.Height()-184)/2; m_pEasyLogo->DrawImage(pDC,nStartX,nStartY); } }
BOOL CAutoPFAView::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default //CScrollView::OnEraseBkgnd(pDC); CAutoPFADoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); /* wndbkBrush.CreateSolidBrush(RGB(128,128,128)); wndbkBrush.DeleteObject(); */ CBrush wndbkBrush; wndbkBrush.CreateSolidBrush(pDoc->m_workSpaceRef.GetbkColor()); FillOutsideRect(pDC,&wndbkBrush);//把组件范围外的区域也刷成客户区域背景颜色,这样看起来不会闪屏 CRect rc(CPoint(0,0),GetTotalSize()); pDC->FillRect(rc, &wndbkBrush); wndbkBrush.DeleteObject(); return TRUE; }