Query of the scaling (Zoom/HiDPI) level of ComBar?
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=23526
Printed Date: 24 November 2024 at 6:22am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Query of the scaling (Zoom/HiDPI) level of ComBar?
Posted By: Fritzchen
Subject: Query of the scaling (Zoom/HiDPI) level of ComBar?
Date Posted: 18 December 2017 at 10:57am
Hello!
I have an urgent question about CommandBar and HiDPI scaling (zoom): The Control CommandBar can automatically resize the icon. This means that you need to know which scaling (zoom) the user has set in Windows.
Can I retrieve this information from the CommandBar control (or any other control of CodeJock Suite)?
That would be a great idea! This would allow a developer to get the HiDPI settings and adjust other controls directly (e. g. reload larger images, adjust other controls, etc.).
It would be really nice if you could provide this information in the CommandBar!
I have the CommandBar 18.0.1 and VB6 Pro.
|
Replies:
Posted By: olebed
Date Posted: 19 December 2017 at 12:54pm
Hello,
Fritzchen wrote:
I have an urgent question about CommandBar and HiDPI scaling (zoom):The Control CommandBar can automatically resize the icon. This means that you need to know which scaling (zoom) the user has set in Windows. |
You don't need to know DPI of your monitor. You just need to load icons with different sizes, multiple 8 - 16х16, 24, 32, 40, 48, 56 and other if you going to use your application in very big monitors.
CommandBars.Icons.LoadBitmap App.Path & "\res\office2013\office2013_16.png", iconsOffice2013IDs, xtpImageNormalCommandBars.Icons.LoadBitmap App.Path & "\res\office2013\office2013_24.png", iconsOffice2013IDs, xtpImageNormal CommandBars.Icons.LoadBitmap App.Path & "\res\office2013\office2013_32.png", iconsOffice2013IDs, xtpImageNormal CommandBars.Icons.LoadBitmap App.Path & "\res\office2013\office2013_40.png", iconsOffice2013IDs, xtpImageNormal
CommandBars.PaintManager.AutoResizeIcons = True CommandBars.Options.SetDPIScallingOptions False, False |
See our sample CommandBars\VB\RibbonSample\frmMain.frm method LoadIcons()
Fritzchen wrote:
Can I retrieve this information from the CommandBar control (or any other control of CodeJock Suite)? |
Private Declare Function GetDpiForMonitor Lib "shcore.dll" (ByVal hMonitor As Long, ByVal dpiType As Long, ByRef dpiX As Long, ByRef dpiY As Long) As Long |
Regards, Oleksandr Lebed
|
Posted By: rmcmanamy
Date Posted: 20 December 2017 at 12:36am
You might also need to calculate your own GetClientRect since I believe the Commandbars returns the wrong one if you are trying to get it in Twips once you set the Windows Text Scaling over 175%. Something like this might work although I haven't tested it on dual monitors with different text scaling.
Public Sub Commadbars_GetClientRect(ByVal oCommandBars As CommandBars, ByRef Left As Long, _ ByRef Top As Long, ByRef Right As Long, ByRef Bottom As Long) On Error Resume Next 'This fixes the GetClientRect bug with 175% and larger Text Scaling Dim oOldScaleMode As XTPScaleMode oOldScaleMode = oCommandBars.ScaleMode oCommandBars.ScaleMode = xtpScalePixel oCommandBars.GetClientRect Left, Top, Right, Bottom oCommandBars.ScaleMode = oOldScaleMode Left = Left * Screen.TwipsPerPixelX Top = Top * Screen.TwipsPerPixelX Right = Right * Screen.TwipsPerPixelX Bottom = Bottom * Screen.TwipsPerPixelY End Sub
------------- Product: Xtreme SuitePro (ActiveX Unicode) version 22.0.0
Platform: Windows 11 (64bit)
Language: Visual Basic 6.0
|
Posted By: Fritzchen
Date Posted: 20 December 2017 at 10:40am
@olebed, rmcmanamy,
thanks for the tips I will test today!
@oledeb: Yes I know that CommandBar can customize the icon itself. Thanks for the advice! My question was, as recognized by rmcmanamy, whether it is possible to query the current DPI via the CommandBar. Under Windows 7 there is no "shcore. dll": - (
I'll try both tips.
Thank you! Fritzchen
|
Posted By: olebed
Date Posted: 21 December 2017 at 7:17pm
http://visualbasic.happycodings.com/forms/code24.html" rel="nofollow - http://visualbasic.happycodings.com/forms/code24.html
' ' Use the GetDeviceCaps API call to ' determine the size of the screen in pixels ' and the conversion factor of Pixels per ' inch. Find the total width & height of the ' screen in Points by multiplying the number ' of Points per Inch (1/72) to the total ' number of inches (Pixels/Pixels per Inch). '
Private Declare Function GetDeviceCaps Lib "gdi32" ( _ ByVal hDc As Long, _ ByVal nIndex As Long _ ) As Long
'Get the conversion of pixels/inch for X & Y varPixToInchX = GetDeviceCaps(hDc, LOGPIXELSX) varPixToInchY = GetDeviceCaps(hDc, LOGPIXELSY)
|
|
Posted By: Fritzchen
Date Posted: 02 January 2018 at 11:12am
Hello everyone,
thanks for your information @olebed. Unfortunately, this doesn't help me either, as the results depend on the resolution and vary depending on the screen (HIDPI).
Question: Is there a way to query the current ICON size in the ribbon bar?
That would be enough for me, because that way I could customize graphics in other controls.
Thanks! Fritzchen
|
Posted By: olebed
Date Posted: 02 January 2018 at 6:33pm
These two functions (GetDpiForMonitor and GetDeviceCaps) are used internally in library.
If you don't set custom icon size for Ribbon/CommandBar or for separately control then used method GetAutoIconSize
CSize CXTPPaintManager::GetAutoIconSize(BOOL bLarge) const{ if (m_bAutoResizeIcons) { int nHeight = GetControlHeight() - XTP_DPI_Y(4); if (bLarge) nHeight = nHeight * 2;
nHeight = max(XTP_DPI_Y(2), nHeight / 8);
return CSize(nHeight * 8, nHeight * 8); }
return bLarge ? CSize(32, 32) : CSize(16, 16); } int CXTPPaintManager::GetControlHeight() const{ return max(XTP_COMMANDBAR_MIN_CONTROL_HEIGHT, m_nEditHeight); } | where m_nEditHeight can be get from RibbonBar.ClientHeight / nRibbonRowCount
"XTP_DPI_Y(4)" can be calculated with GetDpiForMonitor and GetDeviceCaps.
so for my test machine Win7:
100%: 23 - XTP_DPI_Y(4) -> 23 - 4 = 19 -> 16x16 and 32x32 120%: 27 - XTP_DPI_Y(4) -> 27 - 5 = 22 -> 16x16 and 40x40 125%: 29 - XTP_DPI_Y(4) -> 29 - 5 = 24 -> 24x24 and 48x48 135%: 31 - XTP_DPI_Y(4) -> 31 - 5 = 26 -> 24x24 and 48x48 150%: 35 - XTP_DPI_Y(4) -> 35 - 6 = 29 -> 24x24 and 56x56 175%: 41 - XTP_DPI_Y(4) -> 41 - 7 = 34 -> 32x32 and 64x64 200%: 47 - XTP_DPI_Y(4) -> 47 - 8 = 39 -> 32x32 and 72x72
|
Posted By: Fritzchen
Date Posted: 04 January 2018 at 10:38am
Hello @olebed,
thank you for your explanation! That brings me forward now - thank you very much!
Note: Are you on the developer team? The problems with HiDPI must be solved urgently. Controls are drawn with zoom (DPI) > 150% incorrectly. This is a real problem for HiDPI monitors, Surface devices etc...
Is there a correction planned for the upcoming release?
Best regards
Fritzchen
|
Posted By: olebed
Date Posted: 04 January 2018 at 11:59am
Hello Fritzchen,
Yes, I'm from development team, and it is known issue with HiDPI. It is present in our task/bugs list. We are concentrate on other problems now.
Regards, Oleksandr Lebed
|
Posted By: Fritzchen
Date Posted: 04 January 2018 at 6:07pm
Hello Oleksandr, thanks for your quick answer!
Many thanks and good luck for the further development! I'm staying on lookout!
Regards Fritzchen
|
|