Share via


CFont::CreatePointFontIndirect

LOGFONT 構造体の lfHeight メンバーがデバイス単位ではなく 1/10 ポイント単位で解釈されること以外は CreateFontIndirect と同じです。

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

パラメーター

  • lpLogFont
    論理フォントの特性を定義した LOGFONT 構造体へのポインター。 LOGFONT 構造体の lfHeight メンバーは論理単位ではなく 1/10 ポイント単位で計測します。 たとえば、12 ポイントのフォントを指定するには lfHeight を 120 に設定します。

  • pDC
    LOGFONT 構造体の lfHeight メンバーの高さを論理単位に変換するのに使う CDC オブジェクトへのポインター。 NULL を指定したときは、変換に画面デバイス コンテキストを使います。

戻り値

正常終了した場合は 0 以外を返します。それ以外の場合は 0 を返します。

解説

lfHeight の高さは、Windows 上で LOGFONT 構造体が使用される前に pDC で指される CDC オブジェクトを使って論理単位に自動的に変換されます。

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();

必要条件

**ヘッダー:**afxwin.h

参照

参照

CFont クラス

階層図

CFont::CreatePointFont

CFont::CreateFontIndirect

その他の技術情報

CFont のメンバー