Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - Strange Ribbon Group layout on 4k w/ scaling
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Strange Ribbon Group layout on 4k w/ scaling

 Post Reply Post Reply
Author
Message Reverse Sort Order
Fredrik View Drop Down
Senior Member
Senior Member


Joined: 22 June 2005
Status: Offline
Points: 226
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fredrik Quote  Post ReplyReply Direct Link To This Post Topic: Strange Ribbon Group layout on 4k w/ scaling
    Posted: 10 June 2022 at 7:54am
Hi, 

Maybe your problem is same as DPI issues with PNG icons and XTP 20.1 - Codejock Developer Community? It doesn't really sound like that, but who knows - there's an error in GetLargeIconSize anyway.

Try changing this function:

CSize CXTPCommandBar::GetLargeIconSize(BOOL bAutoSize) const
{
...
CSize sz = m_szIcons != CSize(0) ? m_szIcons : (pCommandBars->m_pOptions->szIcons != CSize(0)
                         ? pCommandBars->m_pOptions->szIcons
                         : bAutoSize ? XTPSystemMetrics()->GetSmallIconSize() // <--
                                     : XTP_UNDPI(XTPSystemMetrics()->GetSmallIconSize())); // <--

...
Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
Back to Top
garrettd View Drop Down
Newbie
Newbie
Avatar

Joined: 31 May 2022
Location: Huntsville, AL
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote garrettd Quote  Post ReplyReply Direct Link To This Post Posted: 31 May 2022 at 5:59pm
Normally when I have a RibbonGroup with xtpButtonIconAndCaption controls, the controls are drawn three to a column within the group. However, on a 4k monitor at 200% scaling, only two controls are drawn to a column, resulting in a lot of wasted space. I've traced the problem down to CXTPRibbonGroup::OnCalcDynamicSize(CDC* pDC) in Source\Ribbon\XTPRibbonGroup.cpp. The variable nResultHeight is calculated based on the edit height (x3) plus some padding that winds up being XTP_DPI_Y(1). However, when looping through controls, the control height is calculated based on the control text font. At 4k resolution and 200% scaling, the discrepancy between the edit height and the font height makes OnCalcDynamicSize() think it can only fit two controls in a column.

Has anyone run into this issue before and found a good fix? We are hesitant to change the font size right now, so I'm thinking it might be best to adjust the padding in the calculation for nResultHeight instead. CalcGroupsHeight() adds XTP_DPI_Y(10) and then OnCalcDynamicSize() subtracts XTP_DPI(9) for the nResultHeight calculation - does anyone know where these values came from? Potential side effects for subtracting less?

Thanks,
Garrett
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.141 seconds.