4 ms·
Example of setting DPI awareness: https://github.com/Dwedit/GameStretcher/blob/master/Stretcher/Main.cpp#L51 https://github.com/Dwedit/GameStretcher/blob/master
by Dwedit 1y ago
Example of setting DPI awareness: https://github.com/Dwedit/GameStretcher/blob/master/Stretcher/Main.cpp#L51 https://github.com/Dwedit/GameStretcher/blob/master/Stretche...
This code dynamically checks for and calls one of the following: user32:SetProcessDpiAwarenessContext, shcore:SetProcessDpiAwareness, then user32:SetProcessDPIAware. If the Windows version is extremely old and doesn't implement any of those (Windows XP or earlier), it won't call anything.
- sargstuff 1y agoAh isn't the user32:<windows api functions> a framework not related to 'pure' C?
- jchw 1y agoArguably, Windows itself is an object oriented UI framework.
- sargstuff 1y agoWas going to point out would have to be an embedded program that can be booted into without need of an OS; but then program would still rely on various external api/abi interfaces aka bios, drivers & protocols (usb, scsi, pci, ansi, etc). Given today's hardware, think there's not really a realizstic thing as a realistic reall world 'pure C' program -- way to much knowledge / effort even if exclude NDA's. VM environment for 'hardware' as software still has abi interface, so not 'pure' C at source code level.
- ghewgill 1y agoThe colons there don't represent C++. That's just a way of referring to a windows API function that exists in a specific DLL (in this case "user32"). Because the functions used here do not exist in older versions of Windows, the linked code dynamically loads user32.dll and tries to get the address of those functions so they can be called. That's why you need to know which Windows DLL they exist in.
- scq 1y agoYou can also set it in the application manifest, which is recommended over setting it programmatically: https://learn.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process https://learn.microsoft.com/en-us/windows/win32/hidpi/settin...
- Tringi 1y agoIt's a little more complicated if you are to be using themes, GDI and common controls. Some time ago I put together this example: https://github.com/tringi/win32-dpi https://github.com/tringi/win32-dpi The high DPI support in Windows went through quite an evolution since XP, but mostly to fix what app programmers messed up. You can have nice and crisp XP at 250% dpi if you do things right, e.g.: https://x.com/TheBobPony/status/1733196004881482191/photo/1 https://x.com/TheBobPony/status/1733196004881482191/photo/1