Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default font for all the windows in a Win32 Application?

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?

like image 730
Canopus Avatar asked Jun 02 '09 06:06

Canopus


People also ask

What is the default Windows system font?

Windows 10's default system font, Segoe UI, looks pretty nice. However, if you have something better to replace it with, you can change the default system font on your Windows 10 PC.

How do I make Windows my default font?

Open Start. Search for Notepad and click the top result to open the text editor. Copy and paste the following Registry code onto the file:Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts]"Segoe UI (TrueType)"="segoeui. ttf""Segoe UI Black (TrueType)"="seguibl.

Can you change Windows default font?

Steps to change the default font in Windows 10Step 1: Launch the Control Panel from the Start Menu. Step 2: Click on the “Appearance and Personalization” option from the side menu. Step 3: Click on “Fonts” to open fonts and select the name of the one you want to use as default.

How do I change the default font in settings?

Go to Format > Font > Font. + D to open the Font dialog box. Select the font and size you want to use. Select Default, and then select Yes.


1 Answers

Implement this:

    bool CALLBACK SetFont(HWND child, LPARAM font){
        SendMessage(child, WM_SETFONT, font, true);
        return true;
    }

inside a separate file or just in the main.cpp and then just run:

EnumChildWindows(hwnd, (WNDENUMPROC)SetFont, (LPARAM)GetStockObject(DEFAULT_GUI_FONT));

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 a SetFont.h in my win32 GUI application solutions.

like image 146
Christopher Janzon Avatar answered Oct 15 '22 07:10

Christopher Janzon