古詩詞大全網 - 成語經典 - vc CFont::CreateFont怎麽設定字體間距?

vc CFont::CreateFont怎麽設定字體間距?

使用SetTextCharacterExtra函數。

CFont font;

VERIFY(font.CreateFont(

36, // nHeight

0, // nWidth

0, // nEscapement

0, // nOrientation

FW_NORMAL, // nWeight

FALSE, // bItalic

TRUE, // bUnderline下劃線標記,需要下劃線把這裏設置成TRUE

0, // cStrikeOut

ANSI_CHARSET, // nCharSet

OUT_DEFAULT_PRECIS, // nOutPrecision

CLIP_DEFAULT_PRECIS, // nClipPrecision

DEFAULT_QUALITY, // nQuality

DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily

_T("Arial"))); // lpszFacename

// Do something with the font just created...

CClientDC dc(this);

CFont* def_font = dc.SelectObject(&font);

dc.SetTextCharacterExtra(100);//設置字符間距

dc.TextOut(5, 5, _T("Hello,World!"), 5);

dc.SelectObject(def_font);

// Done with the font. Delete the font object.

font.DeleteObject();