i used mvs 2019 with option 'run code analysis on sulution' alt+f11
I'll have to try that in the IDE. Not familiar with it, so it's something to learn.
About your code above, I had been using GetDeviceCaps() in my original work on this subject which I posted links to earlier from about 5 or 6 years ago. But in my recent reading up on the subject I saw Microsoft's examples were using GetDpiForWindow(). Ever one to stick to my old way of doing things I was resistant to using the newer function, but when I checked out (once again - it's an old function ) MSDN on GetDeviceCaps() I saw this....
Number of pixels per logical inch along the screen width. In a system with multiple display monitors, this value is the same for all monitors.
So since my whole purpose for revisiting this topic was to cover the 'multiple monitor' thing, I thought it best to use the newer function. Don't know if my reasoning is correct, but that's what I did. Just pointing it out. I've never used multiple monitors, but I suppose each could be running at different resolutions. Of course, if one is handling the WM_DPICHANGED message, I suppose that could take care of it anyway.
I think where that negative sign comes into play might be related to the 1st parameter of the CreateFont() function, where whether the nHeight parameter is positive or negative has internal meaning to the function. Check out MSDN on CreateFont() and you'll see what I mean.