Print Page | Close Window

Status bar icon size issues

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=24297
Printed Date: 19 April 2024 at 11:28pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Status bar icon size issues
Posted By: rdhd
Subject: Status bar icon size issues
Date Posted: 15 June 2022 at 11:45am

I have version 20.1


When running on a 4k monitor scaled at 200%, the status bar is only drawing small icons. We create icons that are 16x16, 32x32 and 64x64. When running with the DPI set to 100%, CodeJock paints the 16x16 icon when drawing the CXTPStatusBarPane entries. The button size itself is 16x16 too.

 

Now scale the desktop to 200%. Codejock still draws the 16x16 icon, but the button size is 32x32. This is a regression.


The cause for this is that Codejock is mixing code that uses XTP_DPI_X in CXTPStatusBarPaintManager::DrawStatusBarPaneEntry with calls to CXTPPaintManager::AdjustDpiIconSize. The latter returns 16x16. In earlier versions of CodeJock, code scaled the Icon Extent using XTP_DPI. Hence, the icon was drawn as the same size as the button.

New 20.1 code in DrawStatusBarPaneEntry:

    if (pIcon)

    {

        CSize szIcon = CXTPPaintManager::AdjustDpiIconSize(pIcon, pIcon->GetExtent(),

                                                           XTP_SAFE_GET2(pPane, GetStatusBar(),

                                                                         GetCommandBars(), NULL),

                                                           rcItem.Size());

Pre 20.1:

    if (pIcon)

    {

        CSize szIcon(XTP_DPI(pIcon->GetExtent()));

 

Also, when asking for the icon by calling GetImage on the image manager, CodeJock is always passing in 0 as the icon size ensuring that regardless of the desktop DPI and what images of varying sizes I load, CodeJock will always obtain the smallest image available. So, even if I set the command bar options to auto scale the icon so it AND the button sizes actually match, CodeJock won't use my 32x32 icons and hence the 16x16 image is scaled during the paint op. Since we use PNG images, CJ eventually uses the GDI AlphaBlend API, one cannot even set halftoning on to try and get a better image.


In the very least, should not this status bar pane drawing code be written such that the scaling of the sizes match what this AdjustDpiIconSize are in agreement?




Replies:
Posted By: rdhd
Date Posted: 15 June 2022 at 1:17pm
Just an update. I called EnableDpiBitmapScaling(TRUE); After that, the status bar icons are drawn at the correct size though some of they look like crap due to AlphaBlend not supportig halftone (which isn't that great in and of itself for all images).

So, great! Except ... now CodeJock is scaling ribbon icons too. My desktop is 4k at 200%. I create 64x64 icons and CodeJock gets those icons and then calls the AdjustDPIIconSize and gets back 76x76.

The result is that the buttons draw right over text (when caption below is used as the style), or over the "drop" arrow drawn when a control is a split button dropdown. The call to GetButtonSize goes to the ribbon bar and it is using some "edit" control height which in my case is returned as 41. Then DrawControlToolbarParent changes the size using this weirdness:

szButton = CSize(max(XTP_DPI_X(42), GetControlHeight() * 2 - XTP_DPI_X(4)),
m_nEditHeight > 0 ? m_nEditHeight * 3
   : GetSplitDropDownHeight() + szIcon.cy + XTP_DPI_Y(7));
}
}

and the size ends up 84x123 for a button that has caption below set (the case I stepped thru was for such a button style). That size just isn't suffiient to draw everything. But really, the issue was the auto scaling code just isn't meant to be used when one provides images of the right sizes.

Looks like I have to edit the status bar pane drawing code to go back to what it used to be as there is no way we can live with having our icons scaled by Codejock in all cases.



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