Guest Posted January 10, 2011 Share Posted January 10, 2011 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? . Quote Link to comment Share on other sites More sharing options...
Guest Posted January 13, 2011 Author Share Posted January 13, 2011 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. . Quote Link to comment Share on other sites More sharing options...
Guest Posted January 15, 2011 Author Share Posted January 15, 2011 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. . Quote Link to comment Share on other sites More sharing options...
Guest Posted January 15, 2011 Author Share Posted January 15, 2011 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 . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.