Hi everyone I am curious on how it's possible to make a winform DPI aware when creating it in PowerShell? Or at the very least, prevent it from autoscaling. I've googled it and searched and searched but I just can't seem to find an answer or an example of how to do it. The most common answer is to include it in a manifest, but this is not a viable option for PowerShell.
If anything I just want to prevent Windows from automatically rescaling my forms in DPI higher than 96 (100%). I tried AutoScaleMode = "DPI" and that unfortunately doesn't work and doesn't seem to do anything, as setting it to "None" or not including it at all is the same result.
A quick example...
Add-Type -AssemblyName 'System.Windows.Forms'
Add-Type -AssemblyName 'System.Drawing'
$Dialog = New-Object Windows.Forms.Form
$Dialog.Text = 'Main'
$Dialog.Size = New-Object Drawing.Size(200, 100)
$Dialog.AutoScaleMode = "DPI"
$Label = New-Object Windows.Forms.Label
$Label.Size = New-Object Drawing.Size(200, 16)
$Label.Location = New-Object Drawing.Size(10, 20)
$Label.Text = 'This text is to test autoscaling.'
$Dialog.Controls.Add($Label)
$Dialog.ShowDialog()
The image on the left is autoscaled and blurry. I don't want this, I want it to look like the right. If I can get that far, I'll try to figure out how I'm going to handle the scaling.