I want all the controls (edit,list control, etc) in my application to be having the same font which is not the system default. How do i do this? Is there any Win32 API that sets the application default font?
相关问题
- the application was unable to start correctly 0xc0
- Inheritance impossible in Windows Runtime Componen
- how to get running process information in java?
- Is TWebBrowser dependant on IE version?
- Handle button click in another application
相关文章
- 如何让cmd.exe 执行 UNICODE 文本格式的批处理?
- 怎么把Windows开机按钮通过修改注册表指向我自己的程序
- Warning : HTML 1300 Navigation occured?
- Bundling the Windows Mono runtime with an applicat
- Windows 8.1 How to fix this obsolete code?
- Why windows 64 still makes use of user32.dll etc?
- CosmosDB emulator can't start since port is al
- How to print to stdout from Python script with .py
Windows does not provide any mechanism for an application-wide font. Each window class may have its own behavior for choosing a font to use by default. It may try to select the font used by Windows shell dialogs, or it may simply draw its text using the horrid bitmap 'system' font automatically selected into new DCs.
The Windows common control window classes all respond to
WM_SETFONT
, which is the standard window message for telling a window what font you want it to use. When you implement your own window classes (especially new child control window classes), you should also write a handler forWM_SETFONT
:WM_SETFONT
handler should forward the message to each of them.WM_SETFONT
handler and select it into the DC you use when drawing your window.WM_SETFONT
message.Note that the dialog manager does some of this for you; when instantiating a dialog template, the new dialog's font is set to the font named in the template, and the dialog sends
WM_SETFONT
all of its child controls.Yes you can !
Implement this:
inside a separate file or just in the main.cpp and then just run:
whenever you want, for example in the
WM_CREATE
message, after you've created all your child windows!I always have a
SetFont.cpp
and aSetFont.h
in my win32 GUI application solutions.You can set the font for each Dialog box through the resources view. Right click on a dialog (not on other control), select properties and the font option.
A handy method for setting the font for all child windows in one call:
You can't, there is no way to do this for all controls at the same time. You'll need to set it through the resource editor, as was suggested before, or call SetFont() manually on every control.