VC 字符描边

VC 字符描边

//艺术字体
void DrawTextString(CDC * pDC, LPCTSTR pszString, COLORREF crText, COLORREF crFrame, int nXPos, int nYPos, int aph)
{
//变量定义
int nStringLength=lstrlen(pszString);
int nXExcursion[8]={1,1,1,0,-1,-1,-1,0};
int nYExcursion[8]={-1,0,1,1,1,0,-1,-1};
//int nXExcursion[4]={1,0,-1,0};
//int nYExcursion[4]={0,1,0,-1};

LOGFONT   logfont;
CFont   *oldfont, nowfont;

oldfont=pDC->GetCurrentFont();
oldfont->GetLogFont(&logfont);

logfont.lfEscapement = 10*aph;

nowfont.CreateFontIndirect(&logfont);
oldfont = pDC->SelectObject(&nowfont);

//绘画边框
pDC->SetTextColor(crFrame);
for (int i=0;i<CountArray(nXExcursion);i++)
{
   pDC->TextOut(nXPos+nXExcursion[i],nYPos+nYExcursion[i],pszString,nStringLength);
}

//绘画字体
pDC->SetTextColor(crText);
pDC->TextOut(nXPos,nYPos,pszString,nStringLength);
pDC->SelectObject(oldfont);

return;
}

//超简单描边

void DrawShadow(CDC *pDC, CString & str, COLORREF clrTxt, COLORREF clrBG, int x, int y){ if( pDC == NULL ) return; CPen pen; pDC->SetBkMode(TRANSPARENT); pDC->SetTextColor( clrBG ); for (int i=0; i < 3; i++) { for (int j=0; j < 3; j++) { pDC->TextOut(x+i, y+j, str); } } pDC->SetTextColor( clrTxt ); pDC->TextOut(x+1, y+1, str);} 

你可能感兴趣的:(VC,字符描边)