// 更改当前字体 LOGFONT lf; pDC->GetCurrentFont()->GetLogFont(&lf); CFont font, *pOldFont; lf.lfCharSet=134; lf.lfHeight=-150; lf.lfWidth=0; strcpy(lf.lfFaceName, "隶书"); font.CreateFontIndirect(&lf); pOldFont=pDC->SelectObject(&font); pDC->SetBkMode(TRANSPARENT); // 更改当前画笔为空 CPen pen(PS_NULL, 1, RGB(255, 0, 0)), *pOldPen; pOldPen=pDC->SelectObject(&pen); // 更改当前刷子 CBrush br, *pOldBrush; pOldBrush=pDC->SelectObject(&br); // 开始一个路径 pDC->BeginPath(); pDC->TextOut(10, 10, "渐变字"); pDC->EndPath(); // 绘制渐变效果 pDC->SelectClipPath(RGN_COPY); for (int i=255; i>0; i--) { int iRadius=(600*i)/255; pDC->SelectObject(pOldBrush); br.DeleteObject(); br.CreateSolidBrush(RGB(255, i, 0)); pDC->SelectObject(br); pDC->Ellipse(-iRadius, -iRadius/3, iRadius, iRadius/3); } // 恢复设备上下文的原有设置 pDC->SelectObject(pOldFont); pDC->SelectObject(pOldPen); pDC->SelectObject(pOldBrush);