When I run my WinForm app in Windows in a VM on a retina MacBook Pro, the size of the form shrinks at runtime, while the buttons simultaneously move outward. This can cause buttons at the bottom edge to slip below the window's edge, out of sight. Since they're bottom-anchored, they're rendered completely inaccessible. When run from a Windows-native desktop, the app usually behaves fine.
This only happens with the Font or DPI AutoScaleMode
settings on the form. With Inherit or None, the form and its contents are huge, but directly proportional to how I designed them.
I've reproduced this with a fresh-from-template WinForm app, doing nothing other than resizing the form, and dropping in a button. How can I get the app to scale without the dimensions changing relative to each other?
This is the InitializeComponent()
method in the designer.cs
:
private void InitializeComponent()
{
this.sendButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// sendButton
//
this.sendButton.Location = new System.Drawing.Point(60, 856);
this.sendButton.Margin = new System.Windows.Forms.Padding(4);
this.sendButton.MinimumSize = new System.Drawing.Size(200, 60);
this.sendButton.Name = "sendButton";
this.sendButton.Size = new System.Drawing.Size(200, 62);
this.sendButton.TabIndex = 1004;
this.sendButton.Text = "Send";
this.sendButton.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(282, 981);
this.Controls.Add(this.sendButton);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
Here's a screenshot of the form in the designer:
And at runtime: