MessageBoxOptions 列挙型

定義

MessageBox のオプションを指定します。

この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。

public enum class MessageBoxOptions
[System.Flags]
public enum MessageBoxOptions
[<System.Flags>]
type MessageBoxOptions = 
Public Enum MessageBoxOptions
継承
MessageBoxOptions
属性

フィールド

DefaultDesktopOnly 131072

メッセージ ボックスをアクティブ デスクトップに表示します。 この定数は ServiceNotification に似ていますが、メッセージ ボックスが対話型のウィンドウ ステーションの既定のデスクトップでしか表示されない点が異なります。 メッセージ ボックスを表示したアプリケーションがフォーカスを失い、視覚スタイルを使用せずにメッセージ ボックスが表示されます。 詳細については、「visual スタイルが使用されているコントロールのレンダリング」を参照してください。

RightAlign 524288

メッセージ ボックスのテキストを右揃えで表示します。

RtlReading 1048576

メッセージ ボックスのテキストを右から左へ読むように指定します。

ServiceNotification 2097152

メッセージ ボックスをアクティブ デスクトップに表示します。 呼び出し元は、ユーザーにイベントを通知するサービスです。 Show によって、コンピューターにログオンしているユーザーがいない場合でも、現在アクティブなデスクトップにメッセージ ボックスが表示されます。

次の例では、 パラメーターを含む のオーバーロードMessageBox.Showでサポートされているオプションを使用して を表示MessageBoxする方法をoptions示します。 文字列変数 ServerName( ) が空であることを確認した後、この例では、 に質問ボックス アイコンが表示され、操作を取り消すオプションがユーザーに提供されます MessageBox 。 この例では、 列挙メンバーを MessageBoxOptions.RightAlign 使用して、テキストをダイアログ ボックスの右端に配置します。 メソッドの Show 戻り値が に DialogResult.Yes評価された場合、 を表示した MessageBox フォームは閉じられます。

private:
   void validateUserEntry2()
   {
      // Checks the value of the text.
      if ( serverName->Text->Length == 0 )
      {
         // Initializes the variables to pass to the MessageBox::Show method.
         String^ message = "You did not enter a server name. Cancel this operation?";
         String^ caption = "No Server Name Specified";
         MessageBoxButtons buttons = MessageBoxButtons::YesNo;
         System::Windows::Forms::DialogResult result;
         
         // Displays the MessageBox.
         result = MessageBox::Show( this, message, caption, buttons, MessageBoxIcon::Question, MessageBoxDefaultButton::Button1, MessageBoxOptions::RightAlign );
         if ( result == ::DialogResult::Yes )
         {
            // Closes the parent form.
            this->Close();
         }
      }
   }

private void validateUserEntry2()
{

    // Checks the value of the text.

    if(serverName.Text.Length == 0)
    {

        // Initializes the variables to pass to the MessageBox.Show method.

        string message = "You did not enter a server name. Cancel this operation?";
        string caption = "No Server Name Specified";
        MessageBoxButtons buttons = MessageBoxButtons.YesNo;
        DialogResult result;

        // Displays the MessageBox.

        result = MessageBox.Show(this, message, caption, buttons,
            MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 
            MessageBoxOptions.RightAlign);

        if(result == DialogResult.Yes)
        {

            // Closes the parent form.

            this.Close();
        }
    }
}
Private Sub ValidateUserEntry2()


    ' Checks the value of the text.

    If ServerName.Text.Length = 0 Then

        ' Initializes variables to pass to the MessageBox.Show method.

        Dim Message As String = "You did not enter a server name. Cancel this operation?"
        Dim Caption As String = "No Server Name Specified"
        Dim Buttons As Integer = MessageBoxButtons.YesNo

        Dim Result As DialogResult

        'Displays a MessageBox using the Question icon and specifying the No button as the default.

        Result = MessageBox.Show(Me, Message, Caption, MessageBoxButtons.YesNo, _
            MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign)


        ' Gets the result of the MessageBox display.

        If Result = System.Windows.Forms.DialogResult.Yes Then

            ' Closes the parent form.

            Me.Close()

        End If

    End If

End Sub

注釈

この列挙は、MessageBox クラスで使用します。

MessageBoxメソッドを呼び出すときに引数を指定しない場合は、代わりに 0 を渡すことができます。

適用対象