windows_programming_notes.nbk: Home | Index | Next Page: WM_SETHOTKEY | Previous Page: WM_SETFOCUS


 WM_SETFONT

An application sends a WM_SETFONT message to specify the font that a control is to use when drawing text.

To send this message, call the SendMessage function with the following parameters.

    SendMessage( 
      (HWND) hWnd,              // handle to destination window 
      WM_SETFONT,               // message to send
      (WPARAM) wParam,          // handle to font
      (LPARAM) lParam          // redraw option
    );

Parameters

Return Values

This message does not return a value.

Remarks

The WM_SETFONT message applies to all controls, not just those in dialog boxes.

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; for example, after it destroys the control.

The size of the control does not change as a result of receiving this message. To avoid clipping text that does not fit within the boundaries of the control, the application should correct the size of the control window before it sets the font.

When a dialog box uses the DS_SETFONT style to set the text in its controls, the system sends the WM_SETFONT message to the dialog box procedure before it creates the controls. An application can create a dialog box that contains the DS_SETFONT style by calling any of the following functions:

Requirements


windows_programming_notes.nbk: Home | Index | Next Page: WM_SETHOTKEY | Previous Page: WM_SETFOCUS


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time