Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Example of setting DPI awareness: 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.



You can also set it in the application manifest, which is recommended over setting it programmatically: https://learn.microsoft.com/en-us/windows/win32/hidpi/settin...


It'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

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


Ah isn't the user32:<windows api functions> a framework not related to 'pure' C?


The 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.


Arguably, Windows itself is an object oriented UI framework.


Was 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: