picyka Posted May 13, 2012 Posted May 13, 2012 How to implement a method that seeks an object from another form something like the UniCalendarDialog UniCalendarDialog1.Execute; TuDialogsFrame.UniCalendarDialog1Confirm procedure (Sender: TObject); begin UniLabel2.Caption: = DateToStr (UniCalendarDialog1.Date); end; or something like: UniGUIDialogs.MessageDlg ('Confirm deleting the selected record?' MtConfirmation, mbYesNo, _Confirm); TFCidade._Confirm procedure (AResult: Integer); begin AResult case of mrYes: begin FCidadeService.Delete (Self.FCidade); Self.Close; end; mrNo: edNome.SetFocus; end; end; Quote
Administrators Farshad Mohajeri Posted May 14, 2012 Administrators Posted May 14, 2012 You can already do this with MessageDlg. Quote
picyka Posted May 15, 2012 Author Posted May 15, 2012 Yes, it was one of my inspirations, have to post the source of it, the types of parameters? this would help in the production of my routine. Thank you. Quote
Administrators Farshad Mohajeri Posted May 15, 2012 Administrators Posted May 15, 2012 There are two demos: \demos\Dialogs \demos\Dialogs Anonymous Callback Quote
picyka Posted May 17, 2012 Author Posted May 17, 2012 type TResultObjCallBackAnonProc = reference to procedure (AResult : TAbstractBO); procedure TFConsPadraoObj.InstanceForm(AObj : TAbstractBO; AService : TClass; AProc : TResultObjCallBackAnonProc); begin Self.FListFilter := TObjectList<TFilterColumn>.Create; Self.FService := AService; Self.FResultObj := AObj; Self.CreateClintDataSet(Self.FResultObj); Self.ShowModal; AProc(Self.ResultObj); end; FConsPadraoObj.InstanceForm(Self.FCidade.Estado, TClass(Self.FCidadeService), procedure(ResultObj : TAbstractBO) begin ResultObj.AssignTo(Self.FCidade.Estado); end) I could not understand where food AProc (Self.ResultObj); why so ResultObj User has value after selecting a row. Any tips? Quote
zilav Posted May 17, 2012 Posted May 17, 2012 AProc(Self.ResultObj) is called before form is closed since Self.ShowModal doesn't block execution in unigui. You need to pass that anonymous function to your form and call it in Form.OnClose event. Quote
picyka Posted May 17, 2012 Author Posted May 17, 2012 Yes even thought about it the more I like this method in food on close if it is a parameter to procedure "procedure TFConsPadraoObj.InstanceForm (AObj: TAbstractBO; AService: TClass; AProc:TResultObjCallBackAnonProc); " That could not understand ... Quote
picyka Posted May 20, 2012 Author Posted May 20, 2012 Solution: type TResultObjCallBackAnonProc = reference to procedure (AResult : TAbstractBO); private { Private declarations } FResultObjCallBackAnonProc : TResultObjCallBackAnonProc; procedure TFConsPadraoObj.InstanceForm(AObj : TAbstractBO; AService : TClass; AProc : TResultObjCallBackAnonProc); begin Self.FListFilter := TObjectList<TFilterColumn>.Create; Self.FService := AService; Self.FResultObj := AObj; Self.CreateClintDataSet(Self.FResultObj); Self.ShowModal; FResultObjCallBackAnonProc := AProc; end; procedure TFConsPadraoObj.UniFormClose(Sender: TObject; var Action: TCloseAction); begin FResultObjCallBackAnonProc(ResultObj); end; Quote
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.