Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to call the parent class in VFP?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00024551
Message ID:
00024748
Vues:
39
>>>>>>>I'm a new user of VFP 5.0 and I'm trying to add some code to the button set that is build by the wizard. The problem is that when I add my code in the click method, the parent's code is not working anymore. I tried this.click: but it's not working.
>>>>>>>
>>>>>>>Any help please...
>>>>>>
>>>>>>Try This.Parent.Click()
>>>>>
>>>>>
>>>>>use
>>>>>
>>>>>currentobject::click
>>>>>
>>>>>(two colons together tell vfp to execute the object's inherited code)
>>>>
>>>>You Can Use DEDEFAULT().
>>>Sometimes I don't want to execute all the code from the method of the class. Then I can't use currentobject::click. If it's a class I have defined, or found in WIZSTYLE.VCX or something, I end up pasting the class code in the corresponding method for the object based on it, then editing the code.
>>
>>that's why parent classes you design should have only code that you know you're going to use every time you call the method. if you have extra code that is performed sometimes, put it in another method and in your method, call like this:
>>
>>* always do this code
>>button1::click
>>
>>* extra processing here
>>button1.extraprocess
>>
>>if no extra processing, the click event for button1 (on the form) should be blank and will process the parent code as planned...
>My class is a modification of TXTBTNS from WIZSTYLE.VCX. There is a lot of code in the cmdAdd.click which handles both adding and saving. Whenever I use the class, I have to add code which, when saving, checks all required fields on the form for NOT EMPTY. These fields are, of course, unique to the form. If any are left empty, I make a WAIT WINDOW message and set the focus to the text box containing the missing field. At the bottom is another SetFocus which selects a field unique to that form when you are about to edit, not save.
>It would take me quite a while to figure out how to rewrite all that code so that all lines to be added could come either before or after it. Since the code is working, I am loth to do it anyway. Cutting and pasting is quite easy, although I admit it doesn't feel like the OOP way.

Bret: Why not make two form methods on your form-class, one called PreAdd and one called PostAdd. They would be empty on your form-class, filled in differently in each form. The code in your AddButton.click would be

Thisform.PreAdd() && Does your validation check
CmdAdd::click() && Code from the CmdAdd.click base class
Thiform.PostAdd() && Here's your form-linked setfocus()

Each form would have unique code in the PreAdd and PostAdd sections, which you would fill in as you developed the form.

HTH
Barbara
Barbara Paltiel, Paltiel Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform