Domanda

How do I use an if statement to get the status of a button that was clicked in a `MessageDlg'?

Heres my code:

if MessageDlg('Message',mtError,[mbYesNoCancel],0) = No
    then ShowMessage('Message2');

I saw my IT teacher write something like this a while ago, but I don't remember the syntax.

È stato utile?

Soluzione

The documentation says:

MessageDlg returns the value of the button the user selected. The following table lists the TMsgDlgBtn values for each type of button that can appear in the message box, and the corresponding value that is returned if the user selects that button:

TMsgDlgBtn Value    Corresponding return value
mbOK                mrOk
mbCancel            mrCancel
mbYes               mrYes
mbNo                mrNo
mbAbort             mrAbort
mbRetry             mrRetry
mbIgnore            mrIgnore
mbAll               mrAll
mbNoToAll           mrNoToAll
mbYesToAll          mrYesToAll
mbClose             mrClose

So you need to test for mrNo.

I do recommend that you learn where to find documentation to make your life easier.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top