4k monitor and large buttons |
Post Reply |
Author | |
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
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.
|
|
agontarenko
Admin Group Joined: 25 March 2016 Status: Offline Points: 294 |
Post Options
Thanks(0)
|
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
|
|
agontarenko
Admin Group Joined: 25 March 2016 Status: Offline Points: 294 |
Post Options
Thanks(0)
|
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 |
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
|
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.
|
|
agontarenko
Admin Group Joined: 25 March 2016 Status: Offline Points: 294 |
Post Options
Thanks(0)
|
Hello, Fix will be available in the next beta or final release. Regards, Artem Gontarenko |
|
rdhd
Senior Member Joined: 13 August 2007 Location: United States Status: Offline Points: 886 |
Post Options
Thanks(0)
|
Thanks Artem!
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |