Sign in Join

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

Mailing lists / lazarus / 2014-10

Default button for QuestionDLG

17 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Jürgen Hestermann

How can I specify the default button for QuestionDLG? First I thought that the first button is the default (that's how it worked for Windows XP and Windows 7).
But now on Windows 8.1 suddenly different buttons are used as default.

I saw that MessageDLG allows to define a default button as an extra parameter. But QuestionDLG seems not to have such parameter.
Why not?

On http://lazarus-ccr.sourceforge.net/docs/lcl/dialogs/questiondlg.html it says: "QuestionDlg has the same functionality as MessageDl" But MessageDLG has 6 versions while QuestionDLG only has 2.

Reply by email

Bart
to Jürgen Hestermann
J?rgen Hestermann wrote
How can I specify the default button for QuestionDLG?
function QuestionDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType;
            Buttons: array of const; HelpCtx: Longint): TModalResult;

In the Buttons array of const, add the string 'isdefault' after the button you want to be the default one.

Take a look at the implementation.

Bart

Reply by email

Jürgen Hestermann
to Bart
Bart wrote 8 lines
On 10/12/14, J?rgen Hestermann wrote: > How can I specify the default button for QuestionDLG? function QuestionDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType; Buttons: array of const; HelpCtx: Longint): TModalResult; In the Buttons array of const, add the string 'isdefault' after the button you want to be the default one.

Thanks, it works.
But why is this not mentioned in the documentation at http://lazarus-ccr.sourceforge.net/docs/lcl/dialogs/questiondlg.html ?

Take a look at the implementation.

Is this realy the way how to program in Free Pascal/Lazarus? Find out yourself, there is no documenation and if there is, it is outdated and faulty and missleading?
Too bad.

Reply by email

Jürgen Hestermann
to Jürgen Hestermann
J?rgen Hestermann wrote 12 lines
Am 2014-10-12 um 12:57 schrieb Bart: > On 10/12/14, J?rgen Hestermann wrote: > >> How can I specify the default button for QuestionDLG? > function QuestionDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType; > Buttons: array of const; HelpCtx: Longint): TModalResult; > > In the Buttons array of const, add the string 'isdefault' after the > button you want to be the default one. Thanks, it works.

That was too early. It does not work in all cases. In

case QuestionDlg('File overwrite','File exists. Overwrite it?', mtConfirmation,
[mrNo,'IsDefault',mrYes,mrIgnore,'neVer',mrAll,'All',mrAbort,'Stop '],0) of

it just renames the standard "No" button to "IsDefault".

Reply by email

Jürgen Hestermann
to Jürgen Hestermann
J??rgen Hestermann wrote 22 lines
Am 2014-10-13 um 13:49 schrieb J??rgen Hestermann: > > Am 2014-10-12 um 12:57 schrieb Bart: >> On 10/12/14, J??rgen Hestermann wrote: >> >>> How can I specify the default button for QuestionDLG? >> function QuestionDlg(const aCaption, aMsg: string; DlgType: TMsgDlgType; >> Buttons: array of const; HelpCtx: Longint): TModalResult; >> >> In the Buttons array of const, add the string 'isdefault' after the >> button you want to be the default one. > > Thanks, it works. That was too early. It does not work in all cases. In case QuestionDlg('File overwrite','File exists. Overwrite it?', mtConfirmation, [mrNo,'IsDefault',mrYes,mrIgnore,'neVer',mrAll,'All',mrAbort,'Stop '],0) of it just renames the standard "No" button to "IsDefault".

It seems that in this case I must add the (otherwise redundant) default text:

case QuestionDlg('File overwrite','File exists. Overwrite it?', mtConfirmation, [mrNo,'No','IsDefault',mrYes,mrIgnore,'neVer',mrAll,'All',mrAbort,'Stop '],0) of

A strange behaviour which IMO *must* be documented instead of leaving everybody guessing. But who knows how it *realy* is supposed to be?

Reply by email

Felipe Monteiro de Carvalho
to Jürgen Hestermann: Thanks, it works. But why is this not mentioned in the documentation at…
J?rgen Hestermann wrote
Is this realy the way how to program in Free Pascal/Lazarus? Find out yourself, there is no documenation and if there is, it is outdated and faulty and missleading? Too bad.

If you send a patch for the docs then the next person looking for this will have better luck. I've documented a lot of things, but of course the frameworks are huge so its never enough.

Felipe Monteiro de Carvalho

Reply by email

Jürgen Hestermann
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 10 lines
On Mon, Oct 13, 2014 at 1:49 PM, J?rgen Hestermann wrote: > Is this realy the way how to program in Free Pascal/Lazarus? > Find out yourself, there is no documenation and if there is, > it is outdated and faulty and missleading? > Too bad. If you send a patch for the docs then the next person looking for this will have better luck. I've documented a lot of things, but of course the frameworks are huge so its never enough.

The problem is, that I don't *know* how it is supposed to be. If I knew it, I would not need a documentation.
So it's a vicious circle.
Actually, the programmer(s) who implement things need to add (at least a fundamental) documentation of how it *should* work.

Even when looking into the code I would never know about the intention of the original coders. He could have made mistakes and I would document bugs as the desired behaviour (not to talk about the much higher effort of someone else trying to find out about foreign code which he was never involved in). That's a bit like giving the code of Linux or Windows to someone who uses it and saying: You can find out how it works by viewing the code. In theory it should be possible if you have some additional lifes available.

Reply by email

Bart
to Jürgen Hestermann: Thanks, it works. But why is this not mentioned in the documentation at…
J?rgen Hestermann wrote
Thanks, it works. But why is this not mentioned in the documentation at http://lazarus-ccr.sourceforge.net/docs/lcl/dialogs/questiondlg.html ?

Good question, it would be very nice if you could supply a patch for the docs.

> Take a look at the implementation. Is this realy the way how to program in Free Pascal/Lazarus?

No, it is not.
I just thought I would give you a quick answer, I almoste never use QuestiobDl, I just had a look at the sources, because I remebered it could be done.

I thouht that would be better than either no answer at all, or "it's not in the docs, go figure it out yourself".

Next time I will refrain myself...

Bart

Reply by email

Reinier Olislagers
to Jürgen Hestermann: The problem is, that I don't *know* how it is supposed to be. If I knew it, I would not…
Show quoted text 5 lines
> On Mon, Oct 13, 2014 at 1:49 PM, J?rgen Hestermann > wrote: >> Is this realy the way how to program in Free Pascal/Lazarus? >> Find out yourself, there is no documenation and if there is, >> it is outdated and faulty and missleading?

Stop complaining, making excuses and start contributing. Contributions can be corrected if needed. No contributions means nothing gets improved.

Reply by email

Jürgen Hestermann
to Reinier Olislagers
Reinier Olislagers wrote 8 lines
>> On Mon, Oct 13, 2014 at 1:49 PM, J?rgen Hestermann >> wrote: >>> Is this realy the way how to program in Free Pascal/Lazarus? >>> Find out yourself, there is no documenation and if there is, >>> it is outdated and faulty and missleading? Stop complaining, making excuses and start contributing. Contributions can be corrected if needed. No contributions means nothing gets improved.

http://lazarus-ccr.sourceforge.net/docs/lcl/dialogs/questiondlg.html is not a wiki. I cannot make changes (as I did to other Free Pascal documentation already).

Also, I can only make guesses about the behaviour (or need another life for reading and understanding the whole LCL *and* Free Pascal *and* all supported OS'es). QuestionDLG is just one example. I don't know how the whole LCL is constructed and how it interacts with all possible widgetsets. Even when looking into the code I don't have the background to understand most of the routines. Documentation should be done by persons who realy know how it works and not by those who are just wondering about it.
I have already given wrong answers here in the forum because I was just guessing about how it works. Not a good idea IMO.

Reply by email

Reinier Olislagers
to Jürgen Hestermann
J?rgen Hestermann wrote 15 lines
Am 2014-10-13 um 18:29 schrieb Reinier Olislagers: >>> On Mon, Oct 13, 2014 at 1:49 PM, J?rgen Hestermann >>> wrote: >>>> Is this realy the way how to program in Free Pascal/Lazarus? >>>> Find out yourself, there is no documenation and if there is, >>>> it is outdated and faulty and missleading? > Stop complaining, making excuses and start contributing. Contributions > can be corrected if needed. No contributions means nothing gets improved. > http://lazarus-ccr.sourceforge.net/docs/lcl/dialogs/questiondlg.html is not a wiki. I cannot make changes (as I did to other Free Pascal documentation already).

That is why people asked you to provide a patch or a suggested text.

Also, I can only make guesses about the behaviour (or need another life for reading and understanding the whole LCL *and* Free Pascal *and* all supported OS'es).

<snip>

As I said, contributions can be corrected. People who have an overview of everything are in scarce supply.
Nobody is asking you to write the definitive documentation, just a proposoal.
If this sounds too definitive, write up an article in the wiki about QuestionDlg (IIRC there are already sections/pages on showmessage etc) so it can be easily edited/updated by others.
Same happened for other parts of the LCL (e.g. the grids page) and parts of that got back into the LCL XML docs (i.e. the pdf/chm/ccr site).

Thanks,
Reinier

Reply by email

Jürgen Hestermann
to Reinier Olislagers
Reinier Olislagers wrote
That is why people asked you to provide a patch or a suggested text.

What does that mean: "A patch"?
Should I copy and paste the web page into a text editor, make changes and send it back? And where to send it? This list?

Reply by email

Jürgen Hestermann
to Bart
Bart wrote 6 lines
On 10/14/14, Reinier Olislagers wrote: > http://wiki.lazarus.freepascal.org/Dialog_Examples#QuestionDlg Added a note about having to specify Caption when using IsDefault.

That is good. Many Thanks.

But I wonder whether this is the desired behaviour. Shouldn't a single 'IsDefault' string be treated as setting the button as the default button even when no other caption is specified? Assigning 'IsDefault' as button caption seems very uncommon to me.

And yet another important fact regarding QuestionDLG ist the abillity to set keys to answer the dialog (instead of clicking on the buttons). At least on windows (don't know about other OS'es) you can prepend one character in each button caption with an ampersand (&) to make this key answer the dialog too. For example with

QuestionDlg('Writing log file','Stop writing log file?', mtConfirmation,[mrYes,'&Yes',mrNo,'&No','IsDefault'],0)

the Y of 'Yes' and the N of 'No' are shown underlined and Y and N can be used to answer the dialog in the same way as clicking with the mouse. For (mainly) keyboard driven applications this is very important IMO.

When I remember my password I will add this to the wiki too.

But the wiki is not the first place where users look for help. Searching for 'Lazarus QuestionDLG' lets me find
http://lazarus-ccr.sourceforge.net/docs/lcl/dialogs/questiondlg.html at first and it looks like the official (complete) documentation. I would not expect to find additional (important) facts somewhere else (and even when, how long should I search until I give up?). So all these additional documentation need to be added here too.

Reply by email