[Lazarus] MessageDlg default button

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Thu Jan 26 11:26:53 CET 2012



On Thu, 26 Jan 2012, Koenraad Lelong wrote:

> Hi,
>
> I'm using a MessageDlg to show some information, with multiple buttons. 
> Unfortunately, in this case, I would like to have another button as default. 
> Is there a way to do this ?
>
> What I have :
> if MessageDlg('Attention', 'Data does exist, overwrite ?', mtWarning,[mbNo, 
> mbYes],0) = mrYes then ...
>
> I would like the mbNo to be the default button.
>
> Thanks for any pointers,

Do not use Yes/No buttons. Use QuestionDlg and do something like

If QuestionDlg('Attention','Data already exists. What to do',
                mtWarning,[mrYes,'Overwrite',mrNo,'Keep existing data'])=mrYes then

This is a better dialog, and allows you to put the 'default' answer as
mrYes.

Michael.




More information about the Lazarus mailing list