//绘画函数 void CShortMessage::OnPaint() { CPaintDC dc(this); //绘画标题 DrawCaption(&dc); CRect ClientRect; GetClientRect(&ClientRect); int nXExcursion=GetXExcursionPos(); int nYExcursion=GetYExcursionPos(); //绘画背景 COLORREF Color = RGB(170,213,244); dc.FillSolidRect(nXExcursion,nYExcursion,ClientRect.Width()-2*nXExcursion,4,Color); dc.FillSolidRect(nXExcursion,ClientRect.Height()-8,ClientRect.Width()-2*nXExcursion,7,Color); dc.FillSolidRect(nXExcursion,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color); dc.FillSolidRect(ClientRect.Width()-nXExcursion-12,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color); CRect mRect(nXExcursion,190,ClientRect.Width()-2*nXExcursion,ClientRect.Height()); CBrush Brush(Color); dc.FillRect(mRect,&Brush); //创建笔画 CPen BorderPen(PS_SOLID,1,RGB(20,20,20)); CPen * pOldPen=dc.SelectObject(&BorderPen); dc.SelectObject(m_SkinAttribute.m_brBackGround); //绘画内框 CRect rcDrawRect(nXExcursion,nYExcursion,ClientRect.Width()-2*nXExcursion,200); rcDrawRect.DeflateRect(6,4,6,4); dc.RoundRect(&rcDrawRect,CPoint(8,8)); //清理资源 dc.SelectObject(pOldPen); BorderPen.DeleteObject(); //创建笔画 CPen BorderPen1(PS_SOLID,1,m_SkinAttribute.m_crInsideBorder); pOldPen=dc.SelectObject(&BorderPen1); //绘画内框 rcDrawRect.DeflateRect(1,1,1,1); dc.RoundRect(&rcDrawRect,CPoint(8,8)); CRect rcDrawRect1(nXExcursion+9,203,ClientRect.Width()-2*nXExcursion-8,ClientRect.Height()-37); dc.RoundRect(&rcDrawRect1,CPoint(4,4)); //清理资源 dc.SelectObject(pOldPen); BorderPen1.DeleteObject(); return; }
void CHSBControlColor::Paint(Gdiplus::Graphics *pGraphics) { SolidBrush backBrush(ColorDefined[m_index]); pGraphics->FillRectangle(&backBrush, m_Left + 1, m_Top + 1, 24, 18); if (m_Fouced) { Pen BorderPen1(0xFFF29436); Pen BorderPen2(0xFFFFE294); pGraphics->DrawRectangle(&BorderPen1, m_Left, m_Top, 24 + 1, 18 + 1); pGraphics->DrawRectangle(&BorderPen2, m_Left + 1, m_Top + 1, 24 - 1, 18 - 1); } else { Pen BorderPen(0xFF828790, 1); pGraphics->DrawRectangle(&BorderPen, m_Left, m_Top, 24 + 1, 18 + 1); } }
//绘画函数 void CShortMessage::OnPaint() { CPaintDC dc(this); //绘画标题 DrawCaption(&dc); CRect ClientRect; GetClientRect(&ClientRect); int nXExcursion=GetXExcursionPos(); int nYExcursion=GetYExcursionPos(); ///////////////////////////////////////////////////////////////////////////// CRect rcClient1; GetWindowRect(&rcClient1); int nWidth1=rcClient1.Width(); int nHeight1=rcClient1.Height(); //调整判断 if ((nWidth1!=0)&&(nHeight1!=0)) { //框架位置 CRect rcFrame; rcFrame.SetRect(0,0,nWidth1,nHeight1); //窗口区域 CRgn RegionWindow; RegionWindow.CreateRoundRectRgn(rcFrame.left,rcFrame.top,rcFrame.right+1,rcFrame.bottom+1,5,5); //设置区域 SetWindowRgn(RegionWindow,TRUE); } /////////////////////////////////////////////////////////////////////////// //绘画背景 COLORREF Color = RGB(170,213,244); dc.FillSolidRect(nXExcursion,nYExcursion,ClientRect.Width()-2*nXExcursion,4,Color); dc.FillSolidRect(nXExcursion,ClientRect.Height()-8,ClientRect.Width()-2*nXExcursion,7,Color); dc.FillSolidRect(nXExcursion,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color); dc.FillSolidRect(ClientRect.Width()-nXExcursion-12,nYExcursion+4,12,ClientRect.Height()-nYExcursion-9,Color); CRect mRect(nXExcursion,190,ClientRect.Width()-2*nXExcursion,ClientRect.Height()); CBrush Brush(Color); dc.FillRect(mRect,&Brush); //创建笔画 CPen BorderPen(PS_SOLID,1,RGB(20,20,20)); CPen * pOldPen=dc.SelectObject(&BorderPen); dc.SelectObject(m_SkinAttribute.m_brBackGround); //绘画内框 CRect rcDrawRect(nXExcursion,nYExcursion,ClientRect.Width()-2*nXExcursion,200); rcDrawRect.DeflateRect(6,4,6,4); dc.RoundRect(&rcDrawRect,CPoint(8,8)); //清理资源 dc.SelectObject(pOldPen); BorderPen.DeleteObject(); //创建笔画 CPen BorderPen1(PS_SOLID,1,m_SkinAttribute.m_crInsideBorder); pOldPen=dc.SelectObject(&BorderPen1); //绘画内框 rcDrawRect.DeflateRect(1,1,1,1); dc.RoundRect(&rcDrawRect,CPoint(8,8)); CRect rcDrawRect1(nXExcursion+9,203,ClientRect.Width()-2*nXExcursion-8,ClientRect.Height()-37); dc.RoundRect(&rcDrawRect1,CPoint(4,4)); //清理资源 dc.SelectObject(pOldPen); BorderPen1.DeleteObject(); return; }
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()); }