Jump to content

Recommended Posts

Posted

Message from: "Junior/RO"

 

Hi Farshad.

 

It would be nice if we I write a MessageDlg call using anonymous methods. It's far better than using a callback.

 

type

TMessageDlgClosure = reference to procedure(AResult: Integer);

 

This function could have this declaration:

 

function MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; ResultClosure: TMsgDlgClosure);

 

 

And we can use it:

 

MessageDlg('This will delete all data. Confirm?', mtConfirmation, mbYesNo, procedure(AResult: Integer)

begin

case AResult of

mrYes: UniMainModule.DeleteAllData;

mrNo: Close;

end;

end);

 

 

This can be done, Farshad?

.

 

Posted

Message from: "Farshad Mohajeri"

 

"Junior/RO" wrote in message

news:TnDZOpEsLHA.2316@anaxagvs227...

> Hi Farshad.

>

> It would be nice if we I write a MessageDlg call using anonymous methods.

> It's far better than using a callback.

>

> type

> TMessageDlgClosure = reference to procedure(AResult: Integer);

>

> This function could have this declaration:

>

> function MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons:

> TMsgDlgButtons; ResultClosure: TMsgDlgClosure);

>

>

> And we can use it:

>

> MessageDlg('This will delete all data. Confirm?', mtConfirmation,

> mbYesNo, procedure(AResult: Integer)

> begin

> case AResult of

> mrYes: UniMainModule.DeleteAllData;

> mrNo: Close;

> end;

> end);

>

>

> This can be done, Farshad?

 

Yes, doable, but not all Delphi versions support Anonymous methods.

 

 

.

 

Posted

Message from: "Junior/RO"

 

Farshad Mohajeri escreveu:

 

> Yes, doable, but not all Delphi versions support Anonymous methods.

 

True. Anonymous methods is a feature of Delphi 2009 and above.

 

But since that MessageDlg() is not a component, but a function, it is easy to use a IFDEF directive to not compile for Delphi 2006 and Delphi 2007.

.

 

Posted

Message from: "Farshad Mohajeri"

 

"Junior/RO" wrote in message

news:gUBDVQNtLHA.728@anaxagvs227...

> Farshad Mohajeri escreveu:

>

>> Yes, doable, but not all Delphi versions support Anonymous methods.

>

> True. Anonymous methods is a feature of Delphi 2009 and above.

>

> But since that MessageDlg() is not a component, but a function, it is easy

> to use a IFDEF directive to not compile for Delphi 2006 and Delphi 2007.

 

Request logged #770

 

 

.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...