Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Form caption in Main prg
Message
From
12/02/2008 09:38:39
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
12/02/2008 09:27:39
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01291771
Message ID:
01291793
Views:
10
>What you should do is base all your forms on a common class. Anything you do in your class will be executed in all the derived forms. This is called "inheritance".
>
>
>Dear Sir,
>
>I have more than 80 Forms in my project, so how is it possible to replace all forms?

Well, it is easier if you do things correctly from the start <g>.

But, once you have created a suitable base class, you can change the base class from your forms, by "hacking" the form:
use MyForm.scx
browse
Look in the Class and ClassLoc fields.

First, try to create your class, and create one test form based on it. Then, look what information is inserted into the form (see the sample code above), and apply this to all other forms.

IMPORTANT: Before starting to "play" with your forms, make a backup of all your forms. "Hacking" the form (opening it as a table and making changes) may damage the form beyond any repair, if you are not careful.

While this is a lot of work, using inheritance can greatly simplify your programming in the long term. Your base form class can define a common background color, icon, calculate the caption as you were asking, and have some common behavior (methods).

It would be even better to have a class hierarchy. For example, All forms ultimately derive from a class cForm, but forms where you need to change and save data will be based on cDataForm (which, in turn, is based on cForm). In your data forms, you can have the methods for saving data, un-doing changes, and many more. If you have to correct any error that occurs (for example) when you save data, with a correct class design, you will have to do the change in ONE place, instead of correcting each of your (for example) 50 data forms.

The class hierarchy, then, might look like this:
Form && Basic VFP form - you can't do changes here
|-- cForm && Base class for all your forms
    |-- cDataForm && Class for forms that manage data
    |-- cModalForm && Class for dialogs
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform