Skip to content

Instantly share code, notes, and snippets.

@pinecones-sx
Created May 23, 2019 00:47
Show Gist options
  • Save pinecones-sx/2156cdca2b68b1ae228ff612b27a9dfe to your computer and use it in GitHub Desktop.
Save pinecones-sx/2156cdca2b68b1ae228ff612b27a9dfe to your computer and use it in GitHub Desktop.
the button control is appearing too far to the right for some insane reason
[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
Add-Type -AssemblyName System.Windows.Forms, System.Drawing
$formToolbox = New-Object System.Windows.Forms.Form
$formToolbox.Size = New-Object System.Drawing.Size(300,400)
$formToolbox.StartPosition = 'CenterScreen'
$formToolbox.SizeGripStyle = 'Hide'
$formToolbox.ShowInTaskbar = $true
$iconToolbox = New-Object system.drawing.icon $windowIconUNCPath
$formToolbox.Icon = $iconToolbox
$formToolbox.Text = 'that's one bad button'
$formMargin = 20
$textBtn1 = 'too far'
$btn1 = New-Object System.Windows.Forms.Button
$btn1.Text = $textBtn1
$btn1.Width = 100
$btn1.Location = New-Object System.Drawing.Point(
(($formToolbox.Width / 2) - ($btn1.Width / 2)),
($formMargin)
)
$formToolbox.Controls.Add($btn1)
$formToolbox.BringToFront()
$formToolbox.ShowDialog()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment