WM_SETFONT

Version 3.0

This message specifies the font that a dialog box control is to use when drawing text. The best time for the owner of a dialog box control to set the font of the control is when it receives the WM_INITDIALOG message. The application should call the DeleteObject function to delete the font when it is no longer needed, such as after the control is destroyed.

The size of the control is not changed as a result of receiving this message. To prevent Windows from clipping text that does not fit within the boundaries of the control, the application should correct the size of the control window before changing the font.

Parameter

Description

 

wParam

Contains the handle of the font. If this parameter is NULL, the control will draw text using the default system font.

 

lParam

Specifies whether the control should be redrawn immediately upon setting the font. Setting lparam to TRUE causes the control to redraw itself; otherwise, it will not.

 

Comments

Before Windows creates a dialog box with the DS_SETFONT style, Windows sends the WM_SETFONT message to the dialog-box window before creating the controls. An application creates a dialog box with the DS_SETFONT style by calling any of the following functions:

CreateDialogIndirect

CreateDialogIndirectParam

DialogBoxIndirect

DialogBoxIndirectParam

The DLGTEMPLATE data structure which the application passes to these functions must have the DS_SETFONT style set and must contain a FONTINFO data structure that defines the font with which the dialog box will draw text.