Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating/Writing to object methods at run-time?
Message
 
À
27/04/1999 17:21:22
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00212771
Message ID:
00213924
Vues:
36
In your case, I would use a hook operation. Lets say you have two custom properties on your TextBox: cPopUpClass and oHook

In the Init() of the TextBox, you could have code like this:

This.ohook = CreateObject(This.cPopUpClass)

Then, in the RightClick, you could have code like this:

This.oHook.PopUp() && or whatever the method is to display this list.

What are the benefits?:

For starters, you have a separation between what the TextBox does and what the popup class does. If you need to change the behavior of the popup class, you can do so, without disrupting the Textbox. Also, because you have not overloaded the functionality in the TextBox, you can deploy the popup class in different scenarios.

The popup class in this case could be a custom class that does nothing more than create a popup menu with choices. Of course, it coudl also be a modal form with a listbox. It can be anything you want. The important point here is that you are affecting only the popup class itself when a change needs to be made, not the textbox. In this case, the Textbox is the client requesting the services of the popup class. The textbox should know NOTHING about how the popup class does it's work. It should only know the public interface of the popup class.

Hope this helps....






>Hi All,
>
>I have created an enhanced textbox control that has
>a InquiySQL property that can be used to let the user
>popup a list of values by right-clicking the mouse.
>
>This works fine, but in order to do so you need to also
>have the associated PopList control (which is instantiated
>at run-time) in your class.
>
>I am thinking that in good OOP development, the textbox object
>itself should take care of displaying the popup information
>without requiring this external PopList class.
>
>The PopList control is basically a container with a listbox
>inside. I could instantiate these at run-time from inside my
>listbox control, but then how do I make them react the way
>I want? How do I change the methods of these newly instantiated
>objects at run-time?
>
>Can it be done or am I dreaming of a perfect OOP world?
>
>Thanks in advance
>
>Pascal
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform