picyka Posted May 13, 2012 Share 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; Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted May 14, 2012 Administrators Share Posted May 14, 2012 You can already do this with MessageDlg. Link to comment Share on other sites More sharing options...
picyka Posted May 15, 2012 Author Share 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. Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted May 15, 2012 Administrators Share Posted May 15, 2012 There are two demos: \demos\Dialogs \demos\Dialogs Anonymous Callback Link to comment Share on other sites More sharing options...
picyka Posted May 17, 2012 Author Share 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? Link to comment Share on other sites More sharing options...
zilav Posted May 17, 2012 Share 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. Link to comment Share on other sites More sharing options...
picyka Posted May 17, 2012 Author Share 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 ... Link to comment Share on other sites More sharing options...
picyka Posted May 20, 2012 Author Share 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; Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now