We have a Japanese user reporting that a form size is truncated (smaller size, not all controls are shown) on his Japanese machine.
In the windows form .designer.cs file, we have these settings:
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
Moreover, in the form ctor, we have some code that look like that to adjust the form size to the DPI. uThe japanese user has a regular DPI set o 96.
//
// Adjust Form Size from DPIRatio
//
var size = this.Size;
// dpiRatio is 1.0 if DPI is 96,
// dpiRatio is less than 1.0 if DPI higher than 96
var dpiRatio = DPIHelper.DPIRatio;
var newSize = new Size((int)(size.Width/dpiRatio), (int)(size.Height/dpiRatio));
this.MaximumSize = newSize;
this.MinimumSize = newSize;
this.Size = newSize;
I am sure that it comes from the different set of font on Japanese Windows but didn’t find any guidance to follow to handle that on the web. Any idea?
It’s the code in the 2nd snippet that messes this up. East Asian machines often take advantage of a XP feature that allows increasing the system font size without also increasing the DPI. Nice for readability of their intricate characters.
Just remove the code to solve the problem. If you want to make the form unsizable then set its FormBorderStyle to, say, Fixed3D. If you do insist on faking the border then you’ll have to move the Min/MaximumSize assignments to the Load event. Only then is the form’s Size property calculated and corrected for the system font size as well as any user preferences like the size of the border or the size of the caption text. Which btw is another failure mode for your code.