[Lazarus] MessageDlg() return type

Giuliano Colla giuliano.colla at fastwebnet.it
Wed Sep 12 18:07:44 CEST 2012

Il 12/09/2012 17:31, Graeme Geldenhuys ha scritto:
> On 12/09/12 16:09, Giuliano Colla wrote:
>> mrAbort is a modal result which may derive from a dialog, but also from
>> a custom modal form. It has nothing to do with mbAbort, which is a just
> I don't know, from a developer point of those, those two seem to be a 
> lot related (or maybe that's just me).
 From another developer's point of view.

If you're not satisfied with a custom dialog, which is intended for 
minimal standard usage, then you're forced to create your own dialog: a 
modal form, with the buttons and controls you need (I always end up that 
way, except a few trivial cases), which will return a value.

You don't have any use of the mbOK..mbClose set which is just to 
describe the look of a standard dialog.

To close the form maybe you'll pick up a TBitButton of Kind bkAbort, or 
bkOk, just because the glyph is the most appropriate. But if you need to 
know what has been changed on the form when it closes, and maybe you 
need to avoid closing the form if an error has been made in an entry, 
depending on the situation, you'll programmatically change the Modal 
Result of your button to mrChangedField1 mrChangedAllFields, or to 
mrNone, or whatever.

Of course you'll have defined a number of custom modal results, 
appropriate for your applications (such as mrChanged..).

Then your


will return you a value which isn't related neither to a dialog button 
set, nor to the kind of button pressed to close the form, but to the 
actions taken on the form.

That's why I say that in general Modal Result, Button Kind and Button 
Set have nothing to do the one with the other.


More information about the Lazarus mailing list