Abaksoft Posted February 14, 2018 Share Posted February 14, 2018 Hello Friends, I am trying to optimize my code By using ultra lightweight technic sugested by Farshad on : http://www.unigui.com/doc/online_help/free-form.htm But how to get this text, as i am using traditional showCallBack procedure on Asynchrone mode ? Thx. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 14, 2018 Share Posted February 14, 2018 Hi, Can you explain a little more what you wanted ?! Best regards, Quote Link to comment Share on other sites More sharing options...
Ron Posted February 14, 2018 Share Posted February 14, 2018 You call the getText function, which creates the form, and on modalresult then reads the public text property, which triggers the form's private getText function, which reads the edit text and returns control to the app. Interesting way of using a free form, indeed. I tested it and it works, just remember to set the modalresult properties on the buttons... Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 15, 2018 Author Share Posted February 15, 2018 Thank you friends, Yes DelphiDude, that is the purpose. But, in build 1434, the freeForm is showing and the program continue... don't stop onShowModal. Maybe i forgot a property setting !? I will test and come back soon. Thx. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 15, 2018 Author Share Posted February 15, 2018 Mmm... Could'nt get it in 1434. (not tested in 1424). Do i forget something ? @DD, here is a test Case. Thx. Free_Form_Build_1434.zip Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 16, 2018 Author Share Posted February 16, 2018 Hello Friends, I really block ! @DD, any news about the testCase ? @DelphiDude, can you send here a zip of your test ? Thank you in advance. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 17, 2018 Share Posted February 17, 2018 Hi, In this case you should use EnableSynchronousOperations = True 1 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 17, 2018 Author Share Posted February 17, 2018 Hello Farshad, As i don'nt like EnableSynchronousOperations, I am trying to enable it at runtime when i need a freeform, and comeback to False after modalshow. But this rise an exception : "Blocking function showmodal..." So, Is there a way to use your leightweight technic also in a traditional callback show (synchonous = False) ? Thx. Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted February 17, 2018 Share Posted February 17, 2018 So, Is there a way to use your leightweight technic also in a traditional callback show (synchonous = False) ? procedure TMainForm.UniButton2Click(Sender: TObject); var Frm: TUniForm1; begin Frm := TUniForm1.Create(UniApplication); Frm.ShowModal( procedure (Sender: TComponent; Res: Integer) begin if Res = mrOK then begin UniMemo1.Lines.Add(Frm.UniEdit1.Text); end else begin UniMemo1.Lines.Add('!Cancel!'); end; end ); end; 1 Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted February 17, 2018 Administrators Share Posted February 17, 2018 Hello Farshad, As i don'nt like EnableSynchronousOperations, I am trying to enable it at runtime when i need a freeform, and comeback to False after modalshow. But this rise an exception : "Blocking function showmodal..." So, Is there a way to use your leightweight technic also in a traditional callback show (synchonous = False) ? Thx. Then you must use traditional callbacks which are recommended by default. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 17, 2018 Author Share Posted February 17, 2018 Thank you Friends, @Oliver : BRAVO very nice ! Best regards. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 18, 2018 Author Share Posted February 18, 2018 Hello Oliver, procedure TMainForm.UniButton2Click(Sender: TObject); var Frm: TUniForm1; begin Frm := TUniForm1.Create(UniApplication); Frm.ShowModal( procedure (Sender: TComponent; Res: Integer) begin if Res = mrOK then begin UniMemo1.Lines.Add(Frm.UniEdit1.Text); end else begin UniMemo1.Lines.Add('!Cancel!'); end; end ); end; Do we have to free the temporary variable Frm ? Where to put : Frm.Free ? Or is it automatically free ? Thx Quote Link to comment Share on other sites More sharing options...
Oliver Morsch Posted February 18, 2018 Share Posted February 18, 2018 Do we have to free the temporary variable Frm ? Where to put : Frm.Free ? Or is it automatically free ? Set Form2.FreeOnClose to true; then it is automaticly freed. Otherwise you must use .Free in the callback procedure after doing your stuff. 1 Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 18, 2018 Author Share Posted February 18, 2018 Thank you very much Oliver, I prefer the first method : By default freeForm has FreeOnClose = True. So, we don't care about memoryleak. @Farshad, it's a high flying i think, it's necessary to complete the online doc by all these important points. Not obvious ! Thanks to all of you Quote Link to comment Share on other sites More sharing options...
Sherzod Posted February 18, 2018 Share Posted February 18, 2018 Hi, The owner of the free form is not the global application, but the instance handling the current session. Notice also that the form (frm) is automatically released (FreeOnClose is true and a value was assigned to ModalResult). The variable itself will be released after going out-of-scope (when exiting the function GetText). http://www.unigui.com/doc/online_help/free-form.htm Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted February 18, 2018 Author Share Posted February 18, 2018 Thank you DD, Decidedly this topic is not over. What sugest Oliver is not the same : - on the online doc, variable frm is declared on the freeform. It's easy to understand that all will freed on closing the freeForm (FreeOnClose = True). - on the code above (oliver) the frm is declared in a Mainform procedure. That why i couldn't understand the automatic free. Thx again Edited : The code below don't use the online lightweight technic, but a classical way (frm.uniEdit.Text not the tip property Text sugested on online doc). Quote Link to comment Share on other sites More sharing options...
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.