Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - 4k monitor and large buttons
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

4k monitor and large buttons

 Post Reply Post Reply
Author
Message
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 886
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Topic: 4k monitor and large buttons
    Posted: 15 June 2019 at 11:24am
I have a button on my ribbon that uses a 40x40 PNG image. On a non-scaled desktop the control draws fine. When I go to a 4k monitor scaled at 200%, we supply a 80x80 image. The result is that the image draws such that it overlaps the text under the image.

Debugging led me to GetStretchIconSizeDPIAwareness. DPI icon scaling is not enabled so the code goes to the "else" statement.

        //save original size of icon
        szIcon.cx = pImage->GetWidth();
        szIcon.cy = pImage->GetHeight();

        //reduce icon size if it is bigger than control
        if (szIcon.cx > szAvailable.cx || szIcon.cy > szAvailable.cy)
        {
            szAvailable.cx -= nDpiScallingButtonMarginX * 2;
            szAvailable.cy -= nDpiScallingButtonMarginY * 2;

            szIcon = GetStretchIconSize(pImage, szAvailable);
        }

Examining the if statement note sizIcon.cx is 80 and szAvailable is (84,123). So the available size is not reduced by the margins (4 and 4) * 2 and the call to GetStretchIconSize is not made. It appears that this leads to the image displaying over the text that is under the icon (style is icon with caption below).

My quick fix is to avoid allowing images to exceed 64x64. But that isn't really correct. The 80x80 image should display correctly even if it gets slightly reduced.
Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 293
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 26 August 2019 at 6:27am
Hello, I've checked ribbon button with png images 40*40 and 80*80 in 100 DPI and 200 DPI (Office 2016 theme).
I've get next result - see screenshots.
With 100 DPI we can see image go out of the button edge in below, but with 200 DPI all right.


Note: in Ribbon Image Resources specification states the following
"At 96 dpi, large images are 32x32 pixels in size and small images are 16x16 pixels in size." And at 192 dpi, large images are 64x64 pixels in size and small images are 32x32 pixels in size.
(https://docs.microsoft.com/en-us/windows/win32/windowsribbon/windowsribbon-imageformats)
Thus for you can use icon sizes specified in the specification to fix this problem.

Since version 19.0 you can use xaml icons for ribbon it fixed many problems with DPIs.

Regards,
Artem Gontarenko
Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 293
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 26 August 2019 at 7:56am
I've fixed button size and function GetStretchIconSizeDPIAwareness.
Thus icons 40*40 (100 DPI) and 80*80 (200 DPI) are scaled and not go out of the button edge in below.

Regards,
Artem Gontarenko
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 886
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 26 August 2019 at 10:36am
Great! What version will the fix be in?

Even if I can't move to that version, I can see what code change is actually needed and apply the fix locally.
Back to Top
agontarenko View Drop Down
Admin Group
Admin Group


Joined: 25 March 2016
Status: Offline
Points: 293
Post Options Post Options   Thanks (0) Thanks(0)   Quote agontarenko Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2019 at 3:29am
Hello,

Fix will be available in the next beta or final release.

Regards,
Artem Gontarenko
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 886
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 29 August 2019 at 10:44am
Thanks Artem!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.