Vcl.StdCtrls.TCustomButton.ModalResult

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property ModalResult: TModalResult read FModalResult write FModalResult default 0;

C++

__property System::Uitypes::TModalResult ModalResult = {read=FModalResult, write=FModalResult, default=0};

Properties

Type Visibility Source Unit Parent
property public
Vcl.StdCtrls.pas
Vcl.StdCtrls.hpp
Vcl.StdCtrls TCustomButton

Description

Determines whether and how the button closes its (modal) parent form.

Setting the button component's ModalResult property is an easy way to make clicking the button close a modal form. When a button is clicked, the ModalResult property of its parent form is set to the same value as the button's ModalResult property.

For example, if a dialog box has OK and Cancel buttons, their ModalResult properties could be set at design time to mrOk and mrCancel, respectively. At run time, clicking the OK button then changes the dialog's ModalResult property to mrOk, and clicking the Cancel button changes the dialog's ModalResult property to mrCancel. Unless further processing is required, no OnClick event handlers are required for the buttons.

Changes to ModalResult Values at XE2 Release

The XE2 release introduced three new ModalResult values: mrContinue, mrHelp, and mrTryAgain.

In addition, four of the existing ModalResult values changed at XE2. If your applications use any of the following four ModalResult values for TButton, you need to make code changes: mrClose, mrAll, mrNoToAll and mrYesToAll. Since these values are stored as numbers in .dfm files, the values change when you migrate a project to XE2. The values have changed as follows:

  • Before XE2:
    • mrClose=11
    • mrAll=8
    • mrNoToAll=9
    • mrYesToAll=10
  • In XE2:
    • mrClose=8
    • mrAll=12
    • mrNoToAll=13
    • mrYesToAll=14

The following table lists the constants of type TModalResult that are defined for the ModalResult property, along with their values in the XE2 release and XE release (that is, any release before XE2):


Constant Value Meaning Supported Releases  

mrNone

0

None. Used as a default value before the user exits.

All releases

mrOk

idOK = 1

The user exited with OK button.

All releases

mrCancel

idCancel = 2

The user exited with the CANCEL button.

All releases

mrAbort

idAbort = 3

The user exited with the ABORT button.

All releases

mrRetry

idRetry = 4

The user exited with the RETRY button.

All releases

mrIgnore

idIgnore = 5

The user exited with the IGNORE button.

All releases

mrYes

idYes = 6

The user exited with the YES button.

All releases

mrNo

idNo = 7

The user exited with the NO button.

All releases

mrClose

idClose = 8

The user exited with the CLOSE button.

  • In XE = 11
  • In XE2 = 8

mrHelp

idHelp = 9

The user exited with the HELP button.

New in XE2

mrTryAgain

idTryAgain = 10

The user exited with the TRY AGAIN button.

New in XE2

mrContinue

idContinue = 11

The user exited with the CONTINUE button.

New in XE2

mrAll

mrContinue + 1 (12 or $C)

The user exited with the ALL button.

  • In XE = 8
  • In XE2 = 12

mrNoToAll

mrAll +1 (13 or $D)

The user exited with the NO TO ALL button.

  • In XE = 9
  • In XE2 = 13

mrYesToAll

mrNoToAll +1 (14 or $E)

The user exited with the YES TO ALL button.

  • In XE =10
  • In XE2 = 14


For complete information and solutions, see "XE2 values of mrAll, mrNoToAll, mrYesToAll and mrClose" at http://www.bobswart.nl/Weblog/Blog.aspx?RootId=5:5029

See Also

Code Examples