Share via


CFont::CreatePointFontIndirect

這個函式和相同,除了 CreateFontIndirectLOGFONTlfHeight 成員以點是角度的解譯而非單元。

BOOL CreatePointFontIndirect(
   const LOGFONT* lpLogFont,
   CDC* pDC = NULL 
);

參數

  • lpLogFont
    LOGFONT 的點結構定義邏輯字型的特性。 LOGFONT 結構的 lfHeight 成員以點的秒為單位 (而不是邏輯單位。 (例如,將設定為 120 lfHeight 要求 12 點) 的字型。

  • pDC
    要使用的 CDC 物件的指標轉換在 lfHeight 的高度設定為邏輯單位。 如果 NULL,螢幕裝置內容的轉換。

傳回值

不是零,如果成功,則為 0。

備註

這個函式會自動轉換。 lfHeight 的高度設定為邏輯單位使用 pDC 點的 [ CDC 物件在傳遞 LOGFONT 結構之前加入至視窗。

當您完成使用 CreatePointFontIndirect 函式時所建立的 CFont 物件,請先選取字型在裝置內容之外,然後刪除 CFont 物件。

範例

// The code fragment shows how to create a font object,
// select the font object into a DC (device context) for text
// drawing, and finally delete the font object.
LOGFONT lf;

// clear out structure.
memset(&lf, 0, sizeof(LOGFONT));

// request a 12-pixel-height font
lf.lfHeight = 120;

// request a face name "Arial".
_tcsncpy_s(lf.lfFaceName, LF_FACESIZE, _T("Arial"), 7);  

CClientDC dc(this);

CFont font;
VERIFY(font.CreatePointFontIndirect(&lf, &dc));   

// Do something with the font just created...
CFont* def_font = dc.SelectObject(&font);
dc.TextOut(5, 5, _T("Hello"), 5);
dc.SelectObject(def_font);

// Done with the font. Delete the font object.
font.DeleteObject();

需求

Header: afxwin.h

請參閱

參考

CFont 類別

階層架構圖

CFont::CreatePointFont

CFont::CreateFontIndirect