Job
Job

Reputation: 505

How to make GUI size fixed size in every computer using powershell?

I have an GUI, I want to make the size of the GUI will be the same no matter size of the computer. I tried this, but when I execute in the bigger display, the size of the GUI is bigger, if I execute in small display, the GUI become small size.

Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Application]::EnableVisualStyles()


$Form                            = New-Object system.Windows.Forms.Form
$Form.ClientSize                 = '1085,650'
$Form.text                       = "FORM"
$Form.BackColor                  = "#f6f6f6"
$Form.AutoSize                   = $true
$Form.FormBorderStyle            = "FixedDialog"
$Form.MaximizeBox                = $false
$Form.startposition              = "centerscreen"

$Groupbox1                       = New-Object system.Windows.Forms.Groupbox
$Groupbox1.height                = 592
$Groupbox1.width                 = 1047
$Groupbox1.text                  = "INFO"
$Groupbox1.Font                  = 'Microsoft Sans Serif,9'
$Groupbox1.location              = New-Object System.Drawing.Point(18,14)
$Groupbox1.AutoSize              = $true
$Groupbox1.ForeColor             = "#032d5d"

$Button1                         = New-Object system.Windows.Forms.Button
$Button1.BackColor               = "#136aa4"
$Button1.text                    = "OK"
$Button1.width                   = 70
$Button1.height                  = 27
$Button1.location                = New-Object System.Drawing.Point(960,57)
$Button1.Font                    = 'Microsoft Sans Serif,10'
$Button1.AutoSize                = $true
$Button1.ForeColor               = "#ffffff"

Upvotes: 2

Views: 2884

Answers (1)

Scepticalist
Scepticalist

Reputation: 3923

Try specifying autosize and autoscaling off maybe?

$form.AutoScale = $false
$form.AutoSize = $false

You have to be careful with this though, you run the risk of the form being unreadable on very high resolution displays.

Upvotes: 1

Related Questions