cls
function HelloWord{
[System.Windows.Forms.MessageBox]::Show("Hello world!")
}
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$app=[System.Windows.Forms.Application];
$myForm=new-object System.Windows.Forms.Form;
$myForm.Text="my window";
$button1 = new-object System.Windows.Forms.Button;
$button1.Size = new-object System.Drawing.Size -argumentlist 75, 23;
$button1.Text = "点我试试";
$textbox1=new-object System.Windows.Forms.TextBox;
$textBox1.Multiline = $true;
$textBox1.Text = "hello world";
$textBox1.Size = new-object System.Drawing.Size -argumentlist 281, 227;
$flowLayoutPanel1 = new-object System.Windows.Forms.FlowLayoutPanel;
$myForm.Controls.Add($flowLayoutPanel1)
$flowLayoutPanel1.Controls.Add($textBox1);
$flowLayoutPanel1.Controls.Add($button1);
$flowLayoutPanel1.Dock = "Fill";
$flowLayoutPanel1.FlowDirection = "TopDown";
$button1ClickEventHandler = [System.EventHandler] {
param
(
[Object] $sender,
[EventArgs] $e
)
[System.Windows.Forms.MessageBox]::Show("Hello world!");
}
#$button1.Add_Click($button1ClickEventHandler);
$button1.Add_Click({HelloWord});
#$button1.Add_Click(
#{
#[System.Windows.Forms.MessageBox]::Show("Hello world!");
#}
#);
$app::EnableVisualStyles()
$app::Run($myForm)