Print Page | Close Window

Strange Ribbon Group layout on 4k w/ scaling

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=24292
Printed Date: 21 November 2024 at 11:13am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Strange Ribbon Group layout on 4k w/ scaling
Posted By: garrettd
Subject: Strange Ribbon Group layout on 4k w/ scaling
Date 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



Replies:
Posted By: Fredrik
Date Posted: 10 June 2022 at 7:54am
Hi, 

Maybe your problem is same as  https://forum.codejock.com/dpi-issues-with-png-icons-and-xtp-20-1_topic24214.html" rel="nofollow - 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



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