![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 4 of 4 total |
![]() |
Fri, Aug 14 2015 8:51 AM | Permanent Link |
squiffy Telemix Ltd. | Probably more of a general Pascal question that EWB, but why can't I do this? Or more specifically, how should I pass a form class to a procedure or function to allow me to create a new instance of it? I'm trying to create a single creation routine for a range of forms that are selected from a menu. The actual routine will do more than just create it, but I've trivialised its function for brevity.
If I create this - procedure test( myvar : TForm); var tmp : TForm; begin tmp:=myvar.Create(nil); tmp:=myvar.Show; end; then call it from elsewhere in the same unit like this test(TmyFormDefinedInAnotherUnit); I get "Unable to get property tcontrol.setparent of undefined or null reference" followed by a big line number from, I assume, the compiled JS. If I swap out Tfrm... (the class name) for just frm..... (the form's name) I get "unable to get property create1 of undefined or null reference" The unit is included with "use" |
Fri, Aug 14 2015 8:58 AM | Permanent Link |
squiffy Telemix Ltd. | Forgot to add if I just do this instead of calling the proc then it works :
Var tmp:TForm; ... tmp:=TfrmIWantToCreate.Create(nil); tmp.Show; I just want to be able to move that bit into a proc or function and have the from class be dynamically passed as a parameter. |
Fri, Aug 14 2015 12:16 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | << Probably more of a general Pascal question that EWB, but why can't I do this? Or more specifically, how should I pass a form class to a procedure or function to allow me to create a new instance of it? I'm trying to create a single creation routine for a range of forms that are selected from a menu. The actual routine will do more than just create it, but I've trivialised its function for brevity. >>
What you want is this type from the WebForms unit: TFormControlClass = class of TFormControl; but you can declare your own, if you want to be more specific: TFormClass = class of TForm; and you can use it like this: procedure test( myvar : TFormClass); var tmp : TForm; begin tmp:=myvar.Create(nil); tmp.Show; end; test(TMyFormClass); Tim Young Elevate Software www.elevatesoft.com |
Fri, Aug 14 2015 2:08 PM | Permanent Link |
squiffy Telemix Ltd. | Works perfectly! Thank you.
|
This web page was last updated on Sunday, March 23, 2025 at 04:39 PM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |