Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding properties to a class
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
The Mere Mortals Framework
Divers
Thread ID:
00785537
Message ID:
00785781
Vues:
9
>Cheers Chris,
>
>So you are saying that I cannot extend the backcolor property from anywhere else (such as the label class) to use with my custom command subclass . . .that sounds extremely restrictive to me.
>

This is generally the way all object oriented languages work. You can't inherit specific behaviors/properties/methods from multiple classes (unless the language supports multiple inheritance, which VFP doesn't). Even with multiple inheritance you can't just inherit one method/property from it. This also doesn't automatically let you turn a label, for example, into a command button.

>So more to the point, how would you get around the problem so that you can have a button of any colour that appears to function as a command button?
>

You could upgrade to VFP 8. If that's not an option, you can simulate this a few different ways. One way is to use the Shape class instead of a button. You will need to add code that makes the shape looked "clicked" when you click on it, though. Another way is to overlay a shape on top of an existing button. You can set the color of the shape.

I would probably subclass a container and drop a button on it. Then I'd drop the shape on top of it and adjust the size. I'd add code to the container's Init() method to automatically size the command button and shape to fit the size of the container. That way, you could easily drop this new control on a form and resize just the container. When the form runs, the button and shape will automatically fit the new size. In the Click() event of the shape, call the Click() method of the button. If you need other behaviors as well (eg. right click), pass these to the command button from the corresponding shape events.

HTH
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform