Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

我们为许可用户提供了部分翻译好的中文文档。您只需登录便可查阅这些文档

warndlg

Create warning dialog box

Syntax

h = warndlg
h = warndlg(warningstring)
h = warndlg(warningstring,dlgname)
h = warndlg(warningstring,dlgname,createmode)

Description

h = warndlg displays a dialog box named, Warning Dialog, containing the message, "This is the default warning." The warndlg function returns the handle of the dialog box in h. The warning dialog box disappears after the user clicks OK.

h = warndlg(warningstring) displays a dialog box entitled, Warning Dialog, containing the message specified by warningstring. The warningstring argument can be a character vector or cell array of character vectors.

To use multiple lines in your warning, define warningstring using either of the following:

  • sprintf with newline characters separating the lines

    warndlg(sprintf('Message line 1 \n Message line 2'))
    
  • Cell arrays of character vectors

    warndlg({'Message line 1';'Message line 2'})
    

h = warndlg(warningstring,dlgname) displays a dialog box with title dlgname.

h = warndlg(warningstring,dlgname,createmode) specifies whether the warning dialog box is modal or nonmodal. Optionally, it can also specify an interpreter for warningstring and dlgname. The createmode argument can be a character vector or a structure.

If createmode is a character vector, it must be one of the values shown in the following table.

createmode ValueDescription
'modal'

Replaces the warning dialog box having the specified Title, that was last created or clicked on, with a modal warning dialog box as specified. All other warning dialog boxes with the same title are deleted. The dialog box which is replaced can be either modal or nonmodal.

'nonmodal' (default)

Creates a new nonmodal warning dialog box with the specified parameters. Existing warning dialog boxes with the same title are not deleted.

'replace'

Replaces the warning dialog box having the specified Title, that was last created or clicked on, with a nonmodal warning dialog box as specified. All other warning dialog boxes with the same title are deleted. The dialog box which is replaced can be either modal or nonmodal.

    Note:   A modal dialog box prevents the user from interacting with other windows before responding. To block MATLAB® program execution as well, use the uiwait function.

    Modal dialogs (created using errordlg, msgbox, or warndlg) replace any existing dialogs created with these functions that also have the same name.

    For more information about modal dialog boxes, see WindowStyle in Figure Properties.

If createmode is a structure, it can have fields WindowStyle and Interpreter. WindowStyle must be one of the options shown in the table above. Interpreter must be 'tex' or 'none'. The default value for Interpreter is 'none'.

Examples

The statement

warndlg('Pressing OK will clear memory','!! Warning !!')

displays this dialog box:

Introduced before R2006a

Was this topic helpful?