Jump to content

Parameter from another form


rencarnacion

Recommended Posts

Hello I'd like to know how I can get Parameter from another form that Use as search.

For example I want to get the Employee Code in a form then I Just Call another form and make my search then how I can get the value when I click on a row of grid

I send a Print Screen That Do exactly why I want to do.

If someone have an example please send it.

 

 

Thanks

Link to comment
Share on other sites

In the search form you can define callback procedure..

 

-------------------

unit SearchForm;

 

interface

 

uses

windows, messages...

type

TCallbackProcedure = procedure of object;

FormSearch = class(TUniForm)

 

private

CallbackProcedure: TCallbackProcedure;

-------------------

 

when you call the search form assign the CallbackProcedure, and if this procedure is assigned, it is to be called/executed on close event of search form

 

Example :

http://forums.unigui.com/index.php?app=core&module=attach&section=attach&attach_id=783

Link to comment
Share on other sites

I try to do it like this but I got an error.

 

I usually set the value in the caller form from the called form referencing then caller form in the called.

From caller

called.showmodal; (that use caller)

caller.component.value := called.value;

caller.component.setfocus;

close called;

Link to comment
Share on other sites

Try this one.

 

Thanks for you example. You example work good but when I try to use for example a DataSet doesn't work

 

FrmSolicitud.edtCodigoEmpleado.Text := QryBuscarEmpleado.FieldByName(

'maenomi').Value;

FrmSolicitud.edtCodigoEmpleado.SetFocus;

 

Close;

 

 

Calling from this Form

 

frmBuscaEmpleado.Show;

 

The Other Problem is that is creating the caller form again I don't know why is a strange behavior

I'm sending a screen shot.

How is possible that you call a form and comeback it create it again.

Link to comment
Share on other sites

Try this one.

 

The was finding out about the thread, and I Notice that if you call a form from the mainform you can send back parameter, but if you call a form from another form that is not the mainform that Unigui autocreate You can't send parameters from the called form to the caller form.

I think that must be a property or something like that in order to put the same properties to the other forms that aren't mainform.

 

Thanks everybody for your help, But I hope to get the way to send parameter back from another form

Link to comment
Share on other sites

Thanks for you example. You example work good but when I try to use for example a DataSet doesn't work

 

FrmSolicitud.edtCodigoEmpleado.Text := QryBuscarEmpleado.FieldByName(

'maenomi').Value;

FrmSolicitud.edtCodigoEmpleado.SetFocus;

 

Close;

 

 

Calling from this Form

 

frmBuscaEmpleado.Show;

 

The Other Problem is that is creating the caller form again I don't know why is a strange behavior

I'm sending a screen shot.

How is possible that you call a form and comeback it create it again.

 

I have no problem with dataset

Here an example with VirtualTable

test.zip

Link to comment
Share on other sites

I have no problem with dataset

Here an example with VirtualTable

 

Thanks, Your Example work because your calling a form from the main form, but If you call another form from another that it not main (AutoCreated, You can't send any paramter to the caller form.

 

try do it with a form that you call from the main form and then call another form and try to do it

Link to comment
Share on other sites

Thanks, Your Example work because your calling a form from the main form, but If you call another form from another that it not main (AutoCreated, You can't send any paramter to the caller form.

 

try do it with a form that you call from the main form and then call another form and try to do it

 

Excuse me, I'm new in UniGui projects but I don't see the difference in the way to create a new form.

In project option all the forms are available and none is declared as autocreate.

Declaring a form as autocreate give an error in compilation.

I've written a simple project (15 forms) using the tecnique I've sent to you, no matter in what level of the form i've use it.

 

In the attached example I use two level and all works.

set_value_01.zip

Link to comment
Share on other sites

I'm New too but I have made the test with the Example that send us and I got the same error, when I call a form from another form that is not the main I always got the same error.

I think that must be a better way to do it than I'm doing.

 

The way I can avoid this error is to put the queries in the Main Module doing like that It's work pretty good.

 

 

 

 

 

Excuse me, I'm new in UniGui projects but I don't see the difference in the way to create a new form.

In project option all the forms are available and none is declared as autocreate.

Declaring a form as autocreate give an error in compilation.

I've written a simple project (15 forms) using the tecnique I've sent to you, no matter in what level of the form i've use it.

 

In the attached example I use two level and all works.

Link to comment
Share on other sites

I'm New too but I have made the test with the Example that send us and I got the same error, when I call a form from another form that is not the main I always got the same error.

I think that must be a better way to do it than I'm doing.

 

The way I can avoid this error is to put the queries in the Main Module doing like that It's work pretty good.

 

I hope that someone more expert can give us an explanation.

Link to comment
Share on other sites

Hello I'd like to know how I can get Parameter from another form that Use as search.

For example I want to get the Employee Code in a form then I Just Call another form and make my search then how I can get the value when I click on a row of grid

I send a Print Screen That Do exactly why I want to do.

If someone have an example please send it.

 

 

Thanks

 

type

TForm2 = class;

 

TForm1 = class

private

oForm2: TForm2;

end;

 

TCallBack = procedure of object;

 

TForm2 = class

private

pCallBack: TCallBack;

public

procedure ReadModal(const pCallBackPar: TCallBack)

end;

 

TForm1.CallForm2;

begin

if oForm2=nil then

oForm2:=TForm2.Create(UniApplication);

oForm2.ReadModal(Form2CallBack);

end;

 

.

.

 

TForm2.Form2CallBack;

begin

try

with oForm2 do

// whatever .. for example assign some value in Form2 to Form1.

finally

oForm2:=nil; // essential to ensure oForm2 doesn't hold a loose pointer !!

end;

end;

 

.

.

 

TForm2.ReadModal(const pCallBackPar: TCallBack);

begin

pCallBack:=pCallBackPar;

ShowModal;

end;

 

TForm2.UniFormClose(Sender: TObject; var Action: TCloseAction);

begin

if Assigned(pCallBack) then

pCallBack;

 

// HERE you call the call back .. if it's previously assigned.

// The callback is executed .. AFTER THAT TForm2 instance is destroyed !!! (free on close action)

 

end;

 

Instead of procedure of object (classic way) you can use 'anonymous methods' .. but the 'concept' is imho exactly the same.

 

Regards

 

Rober

Link to comment
Share on other sites

  • 3 months later...
  • 1 year later...

Excuse me, I'm new in UniGui projects but I don't see the difference in the way to create a new form.

In project option all the forms are available and none is declared as autocreate.

Declaring a form as autocreate give an error in compilation.

I've written a simple project (15 forms) using the tecnique I've sent to you, no matter in what level of the form i've use it.

 

In the attached example I use two level and all works.

Hello , the sample is missing

tks

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...