How can I make the Win32 API window more modern?

I ordered the Windows Fifth Edition program a few days ago and started working with it.

I am starting to learn win32 api, however I have a question. Windows do not look like the modern winxp / win vista / win 7 style at all. How to fix it?

Currently, it looks like that, shitty font and that’s it.

enter image description here

Thanks in advance!

Machiel

+7
c ++ c windows interface winapi
source share
5 answers

To get the font on the right, you must call it after CreateWindow(Ex) :

 NONCLIENTMETRICS ncm; ncm.cbSize = sizeof(NONCLIENTMETRICS); ::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0); HFONT hFont = ::CreateFontIndirect(&ncm.lfMessageFont); ::SendMessage(hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0)); 
+10
source share

You apparently didn’t really read the book. You are looking for WM_SETFONT . There is a reason that common controls are not the first to cover a book.

+4
source share

You can check GetThemeSysFont to fill in the LOGFONT corresponding system font, create it using CreateFontIndirect and WM_SETFONT to assign it to each control you create.

As far as I know, there is no way to set a different default for newly created windows in your application. There is also no way to install all the windows that you have already created in one step (i.e., instead of just scrolling through them all or assigning them separately). An exception is dialog boxes, which when creating resources allow the resource to specify the font used for all controls in the dialog box.

+2
source share

You need to set a font for each WM_SETFONT control, you create a font by passing NONCLIENTMETRICS .lfMessageFont to CreateFontIndirect (use SystemParametersInfo (SPI_GETNONCLIENTMETRICS, ...) to get NONCLIENTMETRICS)

The dialog box uses the MS Shell pseudo- wordal font "@ 8pt on <Vista and" Segoe UI "@ 9pt on> = Vista p>

+1
source share

You might want to post some screenshots about what differences you are saying, this will help you figure out what you need to change.

In general, I would say that you probably need to include an appropriate manifest in your application so that your application uses the latest common controls.

In addition, today most user interfaces are not developed using the SDK style code, it is very difficult to program / support, instead use some kind of user interface library, at least MFC.

0
source share

All Articles