Edit

Share via


SelectFont macro (windowsx.h)

The SelectFont macro selects a font object into the specified device context (DC). The new font object replaces the previous font object.

Syntax

HFONT SelectFont(
    HDC hdc,
    HFONT hfont
);

Parameters

hdc

A handle to the DC.

hfont

A handle to the font object to be selected. The font object must have been created using either CreateFont or CreateFontIndirect.

Return value

Type: HFONT

If SelectFont succeeds, the return value is a handle to the font object being replaced. If an error occurs, the return value is NULL.

Remarks

After an application has finished drawing with the new font object, it should always replace a new font object with the original font object.

The SelectFont macro is equivalent to calling SelectObject as follows:


((HFONT) SelectObject((hdc), (HGDIOBJ)(HFONT)(hfont)))

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header windowsx.h

See also

DeleteFont

SelectObject