Jump to content

Method to return another object FORM


picyka

Recommended Posts

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

 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

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

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

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...