System windows forms messagebox system windows forms messagebox

Message Box Class

Definition

Displays a message window, also known as a dialog box, which presents a message to the user. It is a modal window, blocking other actions in the application until the user closes it. A MessageBox can contain text, buttons, and symbols that inform and instruct the user.

Examples

The following code example shows how to use a MessageBox to inform the user of a missing entry in a TextBox. This example requires that the method is called from an existing form with a TextBox named ServerName on it.

The following code example shows how to ask the user a yes or no question and make a decision based on the response.

Remarks

You cannot create a new instance of the MessageBox class. To display a message box, call the static method MessageBox.Show. The title, message, buttons, and icons displayed in the message box are determined by parameters that you pass to this method.

Methods

Determines whether the specified object is equal to the current object.

(Inherited from Object) GetHashCode()

Serves as the default hash function.

(Inherited from Object) GetType()

Gets the Type of the current instance.

(Inherited from Object) MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object) Show(IWin32Window, String)

Displays a message box in front of the specified object and with the specified text.

Displays a message box in front of the specified object and with the specified text and caption.

Displays a message box in front of the specified object and with the specified text, caption, and buttons.

Displays a message box in front of the specified object and with the specified text, caption, buttons, and icon.

Displays a message box in front of the specified object and with the specified text, caption, buttons, icon, and default button.

Displays a message box in front of the specified object and with the specified text, caption, buttons, icon, default button, and options.

Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file.

Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file and HelpNavigator .

Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file, HelpNavigator , and Help topic.

Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file and Help keyword.

Displays a message box with specified text.

Displays a message box with specified text and caption.

Displays a message box with specified text, caption, and buttons.

Displays a message box with specified text, caption, buttons, and icon.

Displays a message box with the specified text, caption, buttons, icon, and default button.

Displays a message box with the specified text, caption, buttons, icon, default button, and options.

Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button.

Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file.

Читайте также:  Почернел рабочий стол windows

Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file and HelpNavigator .

Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file, HelpNavigator , and Help topic.

Displays a message box with the specified text, caption, buttons, icon, default button, options, and Help button, using the specified Help file and Help keyword.

Returns a string that represents the current object.

Message Box Класс

Определение

Отображает окно сообщения. Displays a message box.

Комментарии

Окно сообщения является готовым модальным диалоговым окном, которое отображает текстовое сообщение для пользователя. A message box is a prefabricated modal dialog box that displays a text message to a user. Вы увидите окно сообщения, вызвав статический Show метод MessageBox класса. You show a message box by calling the static Show method of the MessageBox class. Отображаемое текстовое сообщение — это строковый аргумент, который вы передали Show . The text message that is displayed is the string argument that you pass to Show. Несколько перегрузок Show метода также позволяют указать заголовок заголовка окна. Several overloads of the Show method also enables you to provide a title bar caption.

Чтобы разрешить пользователю закрывать окно сообщения, Show отображает окно сообщения, содержащее кнопку ОК и кнопку Закрыть в строке заголовка. To enable a user to close a message box, Show displays a message box that has an OK button and a Close button in the title bar.

Можно также использовать окно сообщения, чтобы задать пользователю вопрос. You can also use a message box to ask a user a question. Пользователь отвечает, щелкая одну из нескольких кнопок, которые будут отображаться с помощью MessageBoxButton перечисления. The user answers by clicking one of several buttons that you specify to display by using the MessageBoxButton enumeration. Это перечисление можно передать в несколько перегрузок Show метода. You can pass this enumeration to several overloads of the Show method. По умолчанию MessageBoxButton перечисление имеет значение OK . The default value of the MessageBoxButton enumeration is OK.

Вы можете определить, какая кнопка была нажата пользователем, изучив возвращаемое значение Show . You can determine which button a user clicks by examining the value that Show returns. Возвращаемое значение является значением MessageBoxResult перечисления, где каждое значение соответствует одной из кнопок, которые может отображать окно сообщения. The return value is a value of the MessageBoxResult enumeration, where each value equates to one of the buttons that a message box can display. Значение по умолчанию для поля сообщения —, OK так как кнопка » ОК » является кнопкой окна сообщения по умолчанию. The default value for message box is OK because OK is the default message box button. Однако некоторые перегрузки Show метода позволяют указать другое MessageBoxResult значение по умолчанию. However, some overloads of the Show method enable you to provide a different MessageBoxResult default value.

Окна сообщений могут обмениваться информацией, а также задавать вопросы с различной степенью важности. Message boxes can communicate information and can ask questions that have varying degrees of importance. Для обозначения важности в окнах сообщений используются значки. Message boxes use icons to indicate importance. Например, значки могут указывать, является ли сообщение информационным, предупреждением или важным. For example, icons can indicate whether the message is informational, is a warning, or is important. MessageBoxImageПеречисление инкапсулирует набор возможных значков окна сообщения. The MessageBoxImage enumeration encapsulates the set of possible message box icons. По умолчанию окно сообщения не отображает значок. By default, a message box does not display an icon. Однако можно передать MessageBoxImage значение в одну из нескольких Show перегрузок метода, чтобы указать, что окно сообщения содержит значок. However, you can pass a MessageBoxImage value to one of several Show method overloads in order to specify that the message box includes an icon.

Читайте также:  Windows hello устройству не удается распознать вас

Окна сообщений иногда предоставляют специальные функции, например чтение справа налево. Message boxes sometimes provide special functionality, such as right-to-left reading. Поведение окна сообщения можно настроить с помощью одного или нескольких MessageBoxOptions значений перечисления, которые принимаются некоторыми перегрузками Show метода. You can customize the behavior of a message box by using one or more MessageBoxOptions enumeration values that are accepted by some overloads of the Show method.

Окна сообщений всегда имеют окно владельца. Message boxes always have an owner window. По умолчанию владельцем окна сообщения является окно, которое в данный момент активно в приложении на момент открытия окна сообщения. By default, the owner of a message box is the window that is currently active in an application at the time that a message box is opened. Однако можно указать другого владельца для, Window используя одну из нескольких Show перегрузок. However, you can specify another owner for the Window by using one of several Show overloads. Дополнительные сведения о окнах владельца см. в разделе Window.Owner . For more information about owner windows, see Window.Owner.

Дополнительные сведения см. в разделе MessageBox Sample. For more information, see MessageBox Sample.

Методы

Определяет, равен ли указанный объект текущему объекту. Determines whether the specified object is equal to the current object.

(Унаследовано от Object) GetHashCode()

Служит хэш-функцией по умолчанию. Serves as the default hash function.

(Унаследовано от Object) GetType()

Возвращает объект Type для текущего экземпляра. Gets the Type of the current instance.

(Унаследовано от Object) MemberwiseClone()

Создает неполную копию текущего объекта Object. Creates a shallow copy of the current Object.

(Унаследовано от Object) Show(String)

Отображает окно сообщения с сообщением, которое возвращает результат. Displays a message box that has a message and that returns a result.

Отображает окно сообщения с сообщением и заголовком, которое возвращает результат. Displays a message box that has a message and title bar caption; and that returns a result.

Отображает окно сообщения с сообщением, заголовком и кнопкой, которое возвращает результат. Displays a message box that has a message, title bar caption, and button; and that returns a result.

Отображает окно сообщения с сообщением, заголовком, кнопкой и значком, которое возвращает результат. Displays a message box that has a message, title bar caption, button, and icon; and that returns a result.

Отображает окно сообщения с сообщением, заголовком, кнопкой и значком, которое принимает результат окна сообщения по умолчанию и возвращает результат. Displays a message box that has a message, title bar caption, button, and icon; and that accepts a default message box result and returns a result.

Читайте также:  Synology nas клиент для windows

Отображает окно сообщения с сообщением, заголовком, кнопкой и значком, которое принимает результат окна сообщения по умолчанию, совместимо с указанными параметрами и возвращает результат. Displays a message box that has a message, title bar caption, button, and icon; and that accepts a default message box result, complies with the specified options, and returns a result.

Отображает окно сообщения перед указанным окном. Displays a message box in front of the specified window. Окно сообщения отображается с сообщением и возвращает результат. The message box displays a message and returns a result.

Отображает окно сообщения перед указанным окном. Displays a message box in front of the specified window. Окно сообщения отображается с сообщением и заголовком, и возвращает результат. The message box displays a message and title bar caption; and it returns a result.

Отображает окно сообщения перед указанным окном. Displays a message box in front of the specified window. Окно сообщения отображается с сообщением, заголовком и кнопкой, а также возвращает результат. The message box displays a message, title bar caption, and button; and it also returns a result.

Отображает окно сообщения перед указанным окном. Displays a message box in front of the specified window. Окно сообщения отображается с сообщением, заголовком, кнопкой и значком, а также возвращает результат. The message box displays a message, title bar caption, button, and icon; and it also returns a result.

Отображает окно сообщения перед указанным окном. Displays a message box in front of the specified window. Окно сообщения отображается с сообщением, заголовком, кнопкой и значком; принимает результат окна сообщения по умолчанию и возвращает результат. The message box displays a message, title bar caption, button, and icon; and accepts a default message box result and returns a result.

Отображает окно сообщения перед указанным окном. Displays a message box in front of the specified window. Окно сообщения отображается с сообщением, заголовком, кнопкой и значком; принимает результат окна сообщения по умолчанию, совместимо с указанными параметрами и возвращает результат. The message box displays a message, title bar caption, button, and icon; and accepts a default message box result, complies with the specified options, and returns a result.

Возвращает строку, представляющую текущий объект. Returns a string that represents the current object.

Не работает messagebox

Не работает MessageBox!
Код и сама ошибка показаны на скриншоте. В чём проблема и как её решить?

Не работает MessageBox
При компиляции выдает такую ошибку: 1>c:\documents and settings\admin\мои документы\visual studio.

Не работает MessageBox
Не работает след строчка MessageBox(«Test»); Выдает ошибку error C2664: ‘MessageBoxW’ .

messagebox не работает
if (MessageBox(Handle,»Вы уверены?»,»Подтверждение»,MB_YESNO) == IDYES) < .

Тематические курсы и обучение профессиям онлайн
Профессия Разработчик на C++ (Skillbox)
Архитектор ПО (Skillbox)
Профессия Тестировщик (Skillbox)

Ведь gcnew может выкинуть исключение внутри catch.

Добавлено через 3 минуты

Заказываю контрольные, курсовые, дипломные и любые другие студенческие работы здесь или здесь.

Не работает MessageBox() в C++ Builder XE
Привет всем, не могу понять почему не работает MessageBox()! вот код каторый я пробую.

Не работает SetFocus после MessageBox
Пишу на C++ Builder 2010. Проблема в том, что после вызова функции MessageBox, курсор должен.

Windows forms, Не работает MessageBox.
Создал три формы: в первой вопрос в label1: Как вас завут?. Пишем в textBox1 ,И жмем на button1;.

Странно работает Win32::GUI::MessageBox
Добрый день Народ есть в модуле на перле такая строка my $otvet =.

Оцените статью