{ using namespace Gdiplus; CDropShadowEffectTextDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; CRect ClientRect; GetClientRect(&ClientRect); CSize ClientSize(ClientRect.Width(),ClientRect.Height()); RectF theRect(ClientRect.left,ClientRect.top,ClientRect.Width(),ClientRect.Height()); PointF textPos(10, ClientSize.cy/3); CStringW text("文字阴影特效"); FontFamily fontFamily(L"Times New Roman"); Font font(&fontFamily, 100, FontStyleBold, UnitPixel); Graphics g(pDC->m_hDC); LinearGradientBrush b(theRect,Color::Blue,Color::AliceBlue,90.0f); g.FillRectangle(&b,theRect); //Make a small bitmap Bitmap bm(ClientSize.cx/4,ClientSize.cy/4,&g); //Get a graphics object for it Graphics* bmpg = Graphics::FromImage(&bm); // must use an antialiased rendering hint bmpg->SetTextRenderingHint(TextRenderingHintAntiAlias); //this matrix zooms the text out to 1/4 size and offsets it by a little right and down Matrix mx(0.25f,0,0,0.25f,3,3); bmpg->SetTransform(&mx); //The shadow is drawn bmpg->DrawString(text,-1,&font,textPos,NULL,&SolidBrush(Color(128, 0,0,0))); //The destination Graphics uses a high quality mode g.SetInterpolationMode(InterpolationModeHighQualityBicubic); //and draws antialiased text for accurate fitting g.SetTextRenderingHint(TextRenderingHintAntiAlias); //The small image is blown up to fill the main client rectangle g.DrawImage(&bm,theRect,0,0,bm.GetWidth(),bm.GetHeight(),UnitPixel); //finally, the text is drawn on top g.DrawString(text,-1,&font,textPos,NULL,&SolidBrush(Color::White)); }