Print Page | Close Window

4k monitor and large buttons

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=23863
Printed Date: 18 April 2024 at 10:20pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: 4k monitor and large buttons
Posted By: rdhd
Subject: 4k monitor and large buttons
Date 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.



Replies:
Posted By: agontarenko
Date 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


Posted By: agontarenko
Date 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


Posted By: rdhd
Date 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.


Posted By: agontarenko
Date Posted: 29 August 2019 at 3:29am
Hello,

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

Regards,
Artem Gontarenko


Posted By: rdhd
Date Posted: 29 August 2019 at 10:44am
Thanks Artem!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net