Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to run a form saved as a class
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
00400258
Message ID:
00400380
Views:
16
Ed,
Thanks for you very informative reply re Forms as classes.

Regards,
Gerard




>>I normally run forms as : Do Form Myform with Param1,Param2,Param3
>>
>>I am starting to save Forms as classes and now am trying to run a form, but Do Form MyFormClass does not work.
>>
>>Can I still pass parameters to the form if using it as a class ?
>>
>
>You instance your Form saved as a class by using CREATEOBJ() or NEWOBJECT(); parameters would follow the declaration of required arguments to the function at the time you create the object, and the arguments are passed to the Init of the Form class in the same way as they are in DO FORM. If your Form Class MyFormClass is saved in the class library MyClass.VCX:
>
>SET CLASSLIB TO MyClass.VCX ADDITIVE
>MyFormInstance = CREATEOBJ('MyFormClass',Param1, Param2,Param3)
>MyFormInstance.Show()
>*you need a READ EVENTS to provide a wait state.
>
>The variable MyFormInstance would have PRIVATE scoping if not declared explicitly otherwise; if you need to reference it above the level where it's created, you can save the object reference to a member property of an object that will persist for as long as you need it, use the Forms collection of _SCREEN to obtain an object reference as needed, create the variable MyFormInstance as PRIVATE ahead of time in a higher-level procedure or function, or make it a PUBLIC variable (the worst of the alternatives IMO, but it's your headache, not mine...)
>
>Note: you can't use a Form class to return a value at termination the same way that you can using DO FORM ... TO with modal forms; there are other approaches available, and they've been discussed to death in the past two weeks.
Previous
Reply
Map
View

Click here to load this message in the networking platform