簡體   English   中英

如何創建帶有是/否按鈕和信息標記圖標的彈出窗口?

[英]How do I create a popup window with Yes/No buttons and a Information Mark icon?

我需要在 PowerShell 中有一個彈出窗口,其中包含帶有是和否按鈕的信息標記圖標。

我目前的代碼如下:

$wshell = New-Object -ComObject Wscript.Shell
  $answer = $wshell.Popup("Do you want to continue?",0,"Alert",0x4)

if($answer -eq 7){exit}

只有是或否部分。 我也需要一個圖標。

你可以這樣做:

$answer = $wshell.Popup("Do you want to continue?",0,"Alert",64+4)

圖標的如下:

Stop          16
Question      32
Exclamation   48
Information   64

按鈕的值如下:

OK               0
OKCancel         1
AbortRetryIgnore 2
YesNoCancel      3
YesNo            4
RetryCancel      5

所以信息圖標和是/否按鈕是 64 + 4

在這種情況下,IMO 使用問題圖標更有意義,因為您是在提出問題,而不僅僅是傳達信息,因此在這種情況下它將是 32 + 4。

標記到 samgak。 有很多方法可以做你想做的事。

或這個...

[System.Windows.Forms.MessageBox]::Show("We are proceeding with next step." , "Status" , 4, 64)

或這個...

[System.Windows.Forms.MessageBox]::Show("Continue Task?","What a Mess", "YesNo" , "Information" , "Button1")

或這個...

[void][System.Reflection.Assembly]::LoadWithPartialName(‘Microsoft.VisualBasic’) 
# [microsoft.visualbasic.interaction]::Msgbox($message,"$button,$icon",$title)
[Microsoft.VisualBasic.Interaction]::MsgBox(“Do you agree?”, ‘YesNoCancel,Information’, “Respond please”) 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM