我写了一些命令,然后想实现点击关闭窗口的时候,点确认关闭,点取消,窗体保留,不知道该如何设置,麻烦哪位高手指点一下,代码如下
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object System.Windows.Forms.Form
$form.Text = "按钮测试"
$form.Size = New-Object System.Drawing.Size(450,450)
$form.add_closing(
{
$n = [System.Windows.Forms.MessageBox]::Show(" 关 闭 ???", "确认", "yesno","question")
if( $n -eq [System.Windows.Forms.DialogResult]::yes){
[windows.forms.messagebox]::show("确认关闭" ,"返回值","OK" ,"asterisk")
}
else{
[windows.forms.messagebox]::show("拒绝关闭" ,"返回值","OK" ,"warning")
####这边不知道如何设置了
}
}
)
[void] $form.ShowDialog()
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$form = New-Object System.Windows.Forms.Form
$form.Text = "按钮测试"
$form.Size = New-Object System.Drawing.Size(450,450)
$form.add_closing(
{
$n = [System.Windows.Forms.MessageBox]::Show(" 关 闭 ???", "确认", "yesno","question")
if( $n -eq [System.Windows.Forms.DialogResult]::yes){
[windows.forms.messagebox]::show("确认关闭" ,"返回值","OK" ,"asterisk")
}
else{
[windows.forms.messagebox]::show("拒绝关闭" ,"返回值","OK" ,"warning")
####这边不知道如何设置了
}
}
)
[void] $form.ShowDialog()