简体   繁体   English

如何创建带有是/否按钮和信息标记图标的弹出窗口?

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

I need to have a popup window in PowerShell that has the information mark icon with yes & no buttons.我需要在 PowerShell 中有一个弹出窗口,其中包含带有是和否按钮的信息标记图标。

My current code is as follows:我目前的代码如下:

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

if($answer -eq 7){exit}

With only the yes or no part.只有是或否部分。 I need an icon there too.我也需要一个图标。

You can do it like this:你可以这样做:

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

The values for the icons are as follows:图标的如下:

Stop          16
Question      32
Exclamation   48
Information   64

The values for the buttons are as follows:按钮的值如下:

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

So information icon and yes/no buttons is 64 + 4所以信息图标和是/否按钮是 64 + 4

IMO in this situation it makes more sense to use a question icon since you are asking a question rather than just conveying information so it would be 32 + 4 in that case.在这种情况下,IMO 使用问题图标更有意义,因为您是在提出问题,而不仅仅是传达信息,因此在这种情况下它将是 32 + 4。

Tagging on to samgak.标记到 samgak。 There are a number of ways to do what you are after.有很多方法可以做你想做的事。

Or this...或这个...

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

Or this...或这个...

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

Or this...或这个...

[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