rencarnacion Posted October 8, 2012 Posted October 8, 2012 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 Quote
sandro.carrara Posted October 8, 2012 Posted October 8, 2012 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; Quote
Ronak Posted October 9, 2012 Posted October 9, 2012 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§ion=attach&attach_id=783 Quote
rencarnacion Posted October 9, 2012 Author Posted October 9, 2012 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; Quote
rencarnacion Posted October 10, 2012 Author Posted October 10, 2012 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. Quote
rencarnacion Posted October 10, 2012 Author Posted October 10, 2012 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 Quote
sandro.carrara Posted October 10, 2012 Posted October 10, 2012 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 Quote
rencarnacion Posted October 10, 2012 Author Posted October 10, 2012 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 Quote
sandro.carrara Posted October 10, 2012 Posted October 10, 2012 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 Quote
rencarnacion Posted October 10, 2012 Author Posted October 10, 2012 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. Quote
sandro.carrara Posted October 11, 2012 Posted October 11, 2012 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. Quote
lema Posted October 12, 2012 Posted October 12, 2012 Hi Ronny. Try to narrow down the problem and attach here a test project that causes the problem. Quote
alasoft Posted October 12, 2012 Posted October 12, 2012 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 Quote
zekeriye Posted January 14, 2013 Posted January 14, 2013 At designer you must select Aplicationform while selecting new Uniguiform. If you select free form your application doesn't ineractive with other form. Quote
asapltda Posted April 6, 2014 Posted April 6, 2014 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 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.