Hi support,
I think I found an issue with the default behavior of Telerik UI for Winforms on a HighDPI PerMonitorV2 configuration.
The application works correctly and resizes well if moved between screen with different Font Scalings.
However, if the user changes the main screen to one with a different scaling, the application is strangely taking the change into account and would also not come back to its original state.
Attached is a GIF showing the problem and the project. The application on run on screen 3 being main display at 100% FontScale. If I pass Screen 1, the main display (which is 125% font scaled), the icons of the app are made larger (for no reason), going back to screen 1 being the main screen, will not restore the icon to the correct size, unless you make parts of the application being redrawn.
I've a more related question but it's more complex and I won't be able to provide a project for this, so I'm just trying here ;) In our real application (not this test one), when setting PerMonitorV2 mode, we need to have RadControl.EnableRadAutoScale set to false for the controls to resize correctly when changing monitors whereas this [test] application needs it to be let it set to true to kind of do the same thing ?! Any idea on where the difference can come from ?
Thanks & regards,
Benjamin Foucher
Hi Benjamin,
I appreciate the provided stacktrace. I have the code and the demo project, but so far, I haven't been able to observe this crash on my side. At this point, I am not sure why these errors appear on your side. I will need to somehow isolate it in a standalone project so that it can be reproduced each time. This way, I can debug the source code and try to suggest a solution. May I ask you to confirm that using the test application attached here, you are able to see the crash?
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.
Hi Dinko,
Thanks for your reply. That's strange that you cannot get this to fail.
I tried changing the main form to be a Telerik.WinControls.UI.RadRibbonForm but it's even worst ! I am now getting a crash at opening when opening on a screen that does not have the same Font Scaling as the main Windows screen. If I open on the main Windows screen and move the window to another screen scaled differently, it would crash with a very similar stack:
My colleague has the same crash when moving windows over differently scaled screens. Did you try it ?
Here is the stack:
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.RadFormControlBase.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(Windows.Win32.Foundation.HWND hWnd, uint msg, Windows.Win32.Foundation.WPARAM wparam, Windows.Win32.Foundation.LPARAM lparam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.Primitives.dll!Windows.Win32.PInvoke.SetWindowPos(Windows.Win32.Foundation.HWND hWnd, Windows.Win32.Foundation.HWND hWndInsertAfter, int X, int Y, int cx, int cy, Windows.Win32.UI.WindowsAndMessaging.SET_WINDOW_POS_FLAGS uFlags) Unknown
System.Windows.Forms.Primitives.dll!Windows.Win32.PInvoke.SetWindowPos<System.Windows.Forms.Control, Windows.Win32.Foundation.HWND>(System.Windows.Forms.Control hWnd, Windows.Win32.Foundation.HWND hWndInsertAfter, int X, int Y, int cx, int cy, Windows.Win32.UI.WindowsAndMessaging.SET_WINDOW_POS_FLAGS uFlags) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.SetBoundsCore(int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.SetBoundsCore(int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified) Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.RadFormControlBase.SetBoundsCore(int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.SetBounds(int x, int y, int width, int height, System.Windows.Forms.BoundsSpecified specified) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.SetDesktopBounds(int x, int y, int width, int height) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.DesktopBounds.set(System.Drawing.Rectangle value) Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.RadFormControlBase.ScaleControl(System.Drawing.SizeF factor, System.Windows.Forms.BoundsSpecified specified) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.ScaleControl(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.Scale(System.Drawing.SizeF includedFactor, System.Drawing.SizeF excludedFactor, System.Windows.Forms.Control requestingControl, bool causedByFontChanged) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.PerformAutoScale(bool includedBounds, bool excludedBounds, bool causedByFontChanged) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.OnFontChanged(System.EventArgs e) Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.RadFormControlBase.OnFontChanged(System.EventArgs e) Unknown
System.Windows.Forms.dll!System.Windows.Forms.ContainerControl.RescaleConstantsForDpi(int deviceDpiOld, int deviceDpiNew) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.OnHandleCreated.__HandleHighDpi|1028_0() Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.OnHandleCreated(System.EventArgs e) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.OnHandleCreated(System.EventArgs e) Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.RadFormControlBase.OnHandleCreated(System.EventArgs e) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WmCreate(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.WmCreate(ref System.Windows.Forms.Message m) Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.RadFormControlBase.WndProc(ref System.Windows.Forms.Message m) Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(Windows.Win32.Foundation.HWND hWnd, uint msg, Windows.Win32.Foundation.WPARAM wparam, Windows.Win32.Foundation.LPARAM lparam) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Windows.Forms.Primitives.dll!Windows.Win32.PInvoke.CreateWindowEx(Windows.Win32.UI.WindowsAndMessaging.WINDOW_EX_STYLE dwExStyle, string lpClassName, string lpWindowName, Windows.Win32.UI.WindowsAndMessaging.WINDOW_STYLE dwStyle, int X, int Y, int nWidth, int nHeight, Windows.Win32.Foundation.HWND hWndParent, Windows.Win32.UI.WindowsAndMessaging.HMENU hMenu, Windows.Win32.Foundation.HINSTANCE hInstance, object lpParam) Unknown
System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.CreateHandle(System.Windows.Forms.CreateParams cp) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.CreateHandle() Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.CreateHandle() Unknown
Telerik.WinControls.UI.dll!Telerik.WinControls.UI.RadFormControlBase.CreateHandle() Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.Handle.get() Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.SetVisibleCore(bool value) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Form.SetVisibleCore(bool value) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Microsoft.Office.msoloop reason, System.Windows.Forms.ApplicationContext context) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) Unknown
RibbonResizeDiagnostic.dll!RibbonResizeDiagnostic.Program.Main() Line 13 C#
About the example for AutoScaleMode, that's a real differential behavior between the test app and our real heavy program, so it cannot send this, sorry, I just wanted to try here if you knew what could be causing this.
Thanks anyway.
Benjamin F
Hi Benjamin,
Thank you for the detailed report and the test project.
In general, when PerMonitorV2 mode is active, and you change the primary display, Windows reconfigures the virtual desktop coordinate system. During this transition, the effective DPI reported for your window can briefly reflect the DPI of a different monitor.
I have followed the steps demonstrated in the GIF file, but could not observe the described behavior. It seems that this could be related to some other settings. As I am unable to reproduce it on my side, I can't be sure why this is happening on the machine and how you could resolve it. Nevertheless, what I can suggest is to use the RadRibbonForm instead of the MS Form when using our controls. Our RadForm/RadRibbonForm has its own logic for improving the scaling mechanism. In general, using our forms shows better results in DPI scaling functionality.
public sealed class RibbonResizeDiagnosticForm : Telerik.WinControls.UI.RadRibbonForm
{
// ...existing constructor and setup code...
}Regarding your second question. With the R2 2022 version of our controls, we have added some improvements to how our controls are scaled in their parent Forms/RadForms. Setting this property will disable these improvements. From that release to this day, we have received some reports that the DPI is not working as expected. We have fixed most of them. In your post, it was mentioned that setting this property to false fixes the scaling. If you can isolate your structure in a sample project so that I can test it on my side, that will be great. Otherwise, I won't be able to help you with this scenario.
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.