6 jun
2017

Button and Label scaling problems

I have Powershell script with Form and several buttons and would like to use DPI scaling for different client resolution. I read from Creating a DPI-Aware Application topic about autoscale and use it. However all controls didn't use scaling and have same size for different resolution. Please help me to fix this issue.

$form_main = New-Object 'System.Windows.Forms.Form'
$form_main.width=360
$form_main.height=300
$form_main.Icon = Return1CIcon
$form_main.FormBorderStyle = "FixedSingle"
$form_main.Text = "1C Start"
$form_main.MinimizeBox=$False
$form_main.MaximizeBox=$False
$form_main.StartPosition = "CenterScreen"
$form_main.AutoScaleDimensions = New-Object System.Drawing.SizeF([double] 96,[double] 96) 
$form_main.AutoScaleMode = "DPI"
$btn_1c =New-Object System.Windows.Forms.Button
$btn_1c.Size = '150,150'
$btn_1c.BackColor = "White"
$btn_1c.BackgroundImage = Return1cLogo
$btn_1c.BackgroundImageLayout = "Zoom"
$btn_1c.Location ='20,20'
$btn_1c.Name = '1CButton'
$btn_1c.TabIndex=0
$lbl_1c = New-Object System.Windows.Forms.Label
$lbl_1c.Text = "Start 1C"
$lbl_1c.Location = '40,190'
$lbl_1c.TabIndex=2
$btn_1cterm =New-Object System.Windows.Forms.Button
$btn_1cterm.Size = '150,150'
$btn_1cterm.BackColor = "White"
$btn_1cterm.BackgroundImage = Return1cTermLogo
$btn_1cterm.BackgroundImageLayout = "Zoom"
$btn_1cterm.Location ='190,20 '
$btn_1cterm.Name = '1CButtonTerm'
$btn_1cterm.TabIndex=1
$lbl_1cterm = New-Object System.Windows.Forms.Label
$lbl_1cterm.Text = "Start 1c 2"
$lbl_1cterm.Location = '200,190'
$form_main.Controls.Add($btn_1c)
$form_main.Controls.Add($lbl_1c)
$form_main.Controls.Add($btn_1cterm)
$form_main.Controls.Add($lbl_1cterm)
$form_main.Showdialog()

COMENTARIOS

DEJA TU COMENTARIO

© 2017 website by Rubit Corporation