Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-01

MessageDlg default button

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Koenraad Lelong

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,

Koenraad Lelong.

Reply by email

Unknown author
to Koenraad Lelong
Koenraad Lelong wrote 13 lines
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.

Reply by email

Koenraad Lelong
to Unknown author
Show quoted text 10 lines
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.

Thanks Micheal,

Rephrasing my question would have done it also, but that QuestionDlg is more clear, I'm going to use that.
I had never seen that QuestionDlg before.

Koenraad.

Reply by email

shoKwave
to Koenraad Lelong: I'm using a MessageDlg to show some information, with multiple buttons. Unfortunately, in…
Koenraad Lelong wrote 6 lines
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.

Hi,

you can use:

MessageDlg('Attention', 'Data does exist, overwrite ?', mtWarning,[mbNo, mbYes],0, mbNo)

The 6th parameter defines the default button.

Ingo

Reply by email