![]() |
Putting text in a string var in a newly created form before showing it ? - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html) +--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html) +---- Forum: English (https://www.atozed.com/forums/forum-16.html) +----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html) +----- Thread: Putting text in a string var in a newly created form before showing it ? (/thread-1566.html) |
Putting text in a string var in a newly created form before showing it ? - SorenJensen - 03-04-2020 Hi all, This might just be a trivial question I should know the answer to , but I do not seem to find the right way of doing it. I want to create a new form when pressing a button (in the OnClick), move values from the creating form, onto the created form, before showing it. So what I would do is: TIWForm1.Button1.OnClick(sender.... begin TIWForm2.create(self); TIWForm2.value1 := 'test'; TIWForrm2.Show end; In Iwform2 I have vaue1 defined as a string in the public section of the form. IDE accepts the code, but compiler rejects with TIWForm2.value1 := 'test'; Error: Method identifier expected... ".value1" should be a method and TIWForm2.Show; Error: this form of method call only allowed for class methods or constructor. Is this not possible in IW or what Am I doing wrong ? Regards Soren RE: Putting text in a string var in a newly created form before showing it ? - karolm - 03-04-2020 Soron, did you notice that TIWForm1 is defined in "type" section? It is like type in=integer; and what you do is in:= 3; We need a variable of the type to assign its value. Since all delphi components are dynamic variables we need to create them first. There are two ways described below. The first one is not safe as we use a global variable "f". So we create a temporary variable that works only within a "with" statement, described as the second example. It is a little tricky method. Since form.create returns a value, we can intercept the value using "with" the same way as we do it with record variables. https://www.sql.ru/forum/561505/with-tform-create-do RE: Putting text in a string var in a newly created form before showing it ? - SorenJensen - 03-04-2020 Hi Karolm, Thanks for your input. The way to dynamically create forms, I've used before in VCL, using a var of type TForm, but never considered it wiith IW. I'll give it a try and see if I can make it work. Regards Soren RE: Putting text in a string var in a newly created form before showing it ? - pete@pdmagic.com - 03-04-2020 (03-04-2020, 11:04 AM)SorenJensen Wrote: Hi Karolm,Hi Soren, My code for creating forms dynamically looks like this: mEditFilterForm := TcmEditFilterForm.Create(WebApplication); mEditFilterForm.Parent := self; mEditFilterForm.Show; When you're done with the form, rather than calling free(), call mEditFilterForm.release(); This lets the form exist until the next form is rendered. That way variables / controls on the first form don't get freed while you're using them to populate values on the next form. Also, unlike VCL, you can populate values on the form anytime after creation and before rendering. So you can even change form controls after calling .show(). This is because .show() just sets visible to true. In the VCL, the form would render at that moment and then the values would change in front of the user. In Intraweb, the form is displayed until the call returns. So you can make changes anytime and they will all be rendered when the call returns. Pete RE: Putting text in a string var in a newly created form before showing it ? - SorenJensen - 03-05-2020 Hi Pete, Thanks for your proposal. I'll give it a try. Regards Soren RE: Putting text in a string var in a newly created form before showing it ? - EitanArbel - 03-05-2020 hi here is what works for me, and i use it a lot for several years now : assuming : 1. TIWForm2 is in unit "Unit2" add Unit2 to the Uses of Form1\Unit1. Then, TIWForm1.Button1.OnClick(sender.... begin With TIWForm2.create(WebApplication) Do Begin value1 := 'test'; //your public var from Unit2 Show; End; end; good luck ![]() |