void CFontTestDlg::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here HDC hdc = dc.GetSafeHdc(); CFont _font; _font.CreateFont( 15, // height of font 0, // average character width 0, // angle of escapement 0, // base-line orientation angle FW_NORMAL, // font weight 0, // italic attribute option 0, // underline attribute option 0, // strikeout attribute option GB2312_CHARSET, // character set identifier OUT_DEFAULT_PRECIS, // output precision CLIP_DEFAULT_PRECIS, // clipping precision ANTIALIASED_QUALITY, // output quality DEFAULT_PITCH, // pitch and family _T("宋体") // typeface name ); dc.SelectObject(&_font); DrawShadow(hdc, CString("http://blog.youkuaiyun.com/jimmy54,我的BLOG欢迎光临."), RGB(0xff,0xff,0xff), RGB(0xff,0,0), 0, 132 ); _font.DeleteObject(); // Do not call CDialog::OnPaint() for painting messages } void CFontTestDlg::DrawShadow(HDC hDC, CString & str, COLORREF clrTxt, COLORREF clrBG, int x, int y) { CPen pen; SetBkMode(hDC,TRANSPARENT); SetTextColor(hDC, clrBG ); for (int i=0; i < 3; i++) { for (int j=0; j < 3; j++) { TextOut(hDC, x+i, y+j, str, str.GetLength()); } } SetTextColor(hDC, clrTxt ); TextOut(hDC, x+1, y+1, str, str.GetLength()); } BOOL CFontTestDlg::TextOut(HDC hdc, int x, int y, LPCTSTR str, int len) { return ExtTextOut(hdc, x, y, ETO_OPAQUE, 0, str, len, 0); }