DPI scaling issues

Pages: 12
I can't duplicate the problem with the messagebox fuzzy text, everything is just sharp.

i used mvs 2019 with option 'run code analysis on sulution' alt+f11

meanwhile I'm trying to replace -MulDiv with a piece of my own code.
-MulDiv returns a negative number '-32', my code is correct, only the number is positive.
need to do some more puzzling...
1
2
3
4
5
6
7
8
9
        int height; 
           
           // int pixelsPerLogicalInchY =  GetDeviceCaps(hdcScreen, LOGPIXELSY) ;
            height = pointSize * GetDeviceCaps(hdcScreen, LOGPIXELSY) / 72 ;
            
            height = -MulDiv(pointSize, GetDeviceCaps(hdcScreen, LOGPIXELSY), 72);
           
            ReleaseDC(0, hdcScreen);
Last edited on

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


LOGPIXELSX

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.
Topic archived. No new replies allowed.
Pages: 12