문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top