1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| HDC pDC;
if (hdc) pDC=hdc; else pDC = ::GetDC(0);
HDC TmpDC=CreateCompatibleDC(pDC);
//choose the font
HFONT m_Font;
LOGFONT* m_pLF;
m_pLF=(LOGFONT*)calloc(1,sizeof(LOGFONT));
strncpy(m_pLF->lfFaceName,font,31);
m_pLF->lfHeight=lSize;
m_pLF->lfWeight=lWeight;
m_pLF->lfItalic=bItalic;
m_pLF->lfUnderline=bUnderline;
m_pLF->lfQuality = PROOF_QUALITY;
m_pLF->lfOutPrecision = OUT_TT_ONLY_PRECIS;
m_pLF->lfClipPrecision = CLIP_LH_ANGLES | CLIP_DEFAULT_PRECIS;
m_pLF->lfPitchAndFamily = TRUETYPE_FONTTYPE;
m_Font=CreateFontIndirect(m_pLF);
//select the font in the dc
HFONT pOldFont=NULL;
if (m_Font)
pOldFont = (HFONT)SelectObject(TmpDC,m_Font);
else
pOldFont = (HFONT)SelectObject(TmpDC,GetStockObject(DEFAULT_GUI_FONT));
//Set text color
SetTextColor(TmpDC,RGB(255,255,255));
SetBkColor(TmpDC,RGB(0,0,0));
//draw the text
SetBkMode(TmpDC,OPAQUE);
//Set text position;
RECT pos = {0,0,0,0};
long len = strlen(text);
::DrawText(TmpDC,text,len,&pos,0);
//::TextOut( TmpDC, x, y ,text,len);
pos.right+=pos.bottom; //for italics |
Partager