[Lazarus] MessageDlg() return type
graeme at geldenhuys.co.uk
Wed Sep 12 16:44:45 CEST 2012
On 12/09/12 15:16, Graeme Geldenhuys wrote:
> Now what return result is TWidgetSet.PromptUser() supposed to return?
OK, from the LCL API help it says MessageDlg returns the button the user
pressed - expressed as an integer.
wouldn't it also be better to define .PromptUser()'s return type as a
TMsgDlgBtn type? Thus removing any possible confusion.
The help doesn't seem to make sense in reality - or maybe I'm just not
understanding LCL workings very well (quite possible).
Button enums are defined as follows...
TMsgDlgBtn = (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry,
mbAll, mbNoToAll, mbYesToAll, mbHelp, mbClose);
I wrote code as follows...
Result := MessageDlg('My caption','error dialog with custom buttons',
mtError, [mbOK, mbYesToAll, mbAbort, mbHelp], '');
Writeln('Result = ', Result);
At runtime I click on the "Abort" button and the console output is 3
???? I'm using LCL-GTK2.
So what is 3? It's not the enum value of mbAbort, it is also not the set
value of mbAbort in the button set I passed to MessageDlg(). Sets start
from value zero correct? So where does the value 3 come from?
- Graeme -
More information about the Lazarus