Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can you declare a FORM public?
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00044717
Message ID:
00044987
Views:
37
>>>>>
>>>>>Hi Bret and thanks for your comments..
>>>>>How do you use empty formset (containing toolbar only) and add forms (addobject from class) dynamically? Could you show me some code?
>>>>>
>>>>>>>>>>Do you put every form in an app into one big formset?
>>>>>No - I look at life as a group a functions… If you can separate something and still make it work and it can be somewhat generic, than it should be a function. Why would I add a FORM to a FORMSET if it can stand alone and be call on when needed. End of story.
>>>>>I would be willing to listen to other comments on this subject….thans..rob
>>>>
>>>>Using a formset simplifies the references. If you are in form3 and want to do something to form1, you can just say myformset.form1.stuff when you are in form3. The reason I suppose Ed suggests we instantiate forms in a formset with CREATEOBJECT(myformclass) is because if you load a formset with all its forms, they're all in memory at once when you don't need them all, and the whole formset takes longer to load. If your formset contains the toolbar and maybe the first form to be displayed, it loads faster. The button on form1 which I use to load form2 can say form2=CREATEOBJECT(form2class) and form2.Show, rather than DO FORM form2, as it does now. That button could either form1.hide, or it could RELEASE form1 and then CREATEOBJECT(form1class) again later, depending on whether I care more about speed or memory usage. If I have a formset with three simple forms, and I expect the users to go back and forth a lot, I might load 'em all and just show them and hide them. If the
>>formset
>>>>has 15 forms, and some of these have 15 page pageframes and a couple of grids, each with dozens of controls, and embedded pictures, and will be run on an old machine, each form might be better off being CREATEOBJECTed and RELEASEd as needed.
>>>>
>>>>I think people have other OOP reasons for CREATEOBJECTing everything, rather than just using their classes to put stuff into .SCX files, but I don't understand that part yet.
>>>>
>>>>I seem to have made a new verb: to createobject - I createobject, you createobject, he/she createobjects, we createobject, y'all createobject (for Texans) they createobject. :)
>>>
>>>Hi Bret - thank you for your comments.. I have not use CREATEOBJECT. After
>>>reading you comments, I can see some of the value of CREATEOBJECT. Could
>>>you give me some sample code of how to use CREATEOBJECT?
>>>thanks..rob
>>If your formset is a class, then where you would DO FORM myformset, you would instead say
>>oFormset = CREATEOBJECT(myformsetclass)
>>oFormset.Show
>>
>>In the init of your formset, you could show your form1, like so:
>>THIS.AddObject(myformname1,myformclass1,anyparameter1)
>>THIS.myformname1.show
>>
>>If you have a button on form1 that is supposed to show form2, then you could take out the DO FORM form2 and put in
>>THISFORM.Hide
>>THISFORMSET.AddObject(myformname2,myformclass2,anyparameter1)
>>THISFORMSET.myformname2.Show
>>and if form2 is modeless, you might be able to put THISFORM.Release here. Then you'd have to instantiate form1 again elsewhere.
>>
>>The details of where you show, hide, and release forms in your formset will depend on your structure and requirements. Code like this could be in your menu, or perhaps in some event handling method of your application object.
>
>ok - so the advantages of using CREATEOBJECT is a faster load time?
The advantage here is not having to load all the forms in the formset at once. Once you decide to use a formset, each of its forms takes time and memory to load. If you have two forms, each requiring two seconds to load, the formset will require maybe four seconds. Users get restless at about four seconds. If only one of the forms is loaded with the formset, it seems to go fast, and the second form, loaded when it's needed, also goes fast. If the formset has many forms that are really big and complicated, and memory is limited, loading them all at once becomes impossible. Even if you're not close to the limit, it would be bad design to make your app hog memory when it isn't necessary. I would guess that two or three forms with not more than a few dozen controls each will not use much memory compared to many cursors or the VFP runtime module itself. But I'm no resource expert.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform