For the form I do:

hFont := SendMessage(Self.Handle, WM_GETFONT, 0, 0); 

But returns 0. Ie as if the form has a system font. Why is that?

And if you do, for example, like this:

 hFont := SendMessage(CheckBox1.Handle, WM_GETFONT, 0, 0); 

That returns the correct descriptor.

The same, for example, for TPanel - hFont = 0. And for the hFont button - the correct value.

    2 answers 2

    WM_GETFONT is not exactly a system message, you need to process it yourself. Dialogues store a variable in their window object, which they associate with the WM_GETFONT / WM_SETFONT messages:

    When the dialog box is received, it can be defined as the control box. In the process of writing the text box, it will be sent to you. Predefined controls do this by default.

    (see details in Dialog Box Fonts )

    this is done for centralized font management, so that the dialogue can go through all its children and set up this single font.

    The form and the panel are custom Delphi elements (also windows, but not dialogs), so they do not respond to these messages. Delphi does not use classical dialogs at all, so it realizes some of its capabilities in its own way (its bikes).

      WM_GETFONT message

      Control text is currently drawing text.

      It is believed that TForm and TPanel are not Control, from the point of view of WinAPI and WM_GETFONT / WM_SETFONT not applicable to them. Those. the standard window function simply does not process this message.