Jump to content

Recommended Posts

Posted

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; 

Posted

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.

Posted

 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?

Posted

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.

Posted

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

Posted

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;

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