Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to add context menu items in a derived class
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de menu & Menus
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows NT
Database:
Visual FoxPro
Divers
Thread ID:
01025165
Message ID:
01025527
Vues:
14
Sergey,

I don't think this example helps with what I am trying to do. Briefly. I want to create a image class, let me call it ImageA. I will create a context menu for this that includes two items: Copy and Properties. I add code to the class to handle these two items: Copy - copy the image to the clipboard. Properties - display information about the image. This is functionality that I want to be inherited by derived classes.

So, then, I derive two classes from the ImageA class. Call them ImageB and ImageC. I want these classes to have context menus too. Each should include the Copy and Properties items. But each will include other items that are specific to the new classes.

I would like to be able to inherit the context menus from ImageA. I know that I will inherit the methods that perform the functionality of the menu items, but as far as I can see, ImageB and ImageC must explicitly include the Copy and Properties menu items in the context menus they create.

A code fragment of the way I handle this is below. I have two methods: The RightClick event handler, and ShortCutMenuAdd() to create and execute the context menu:

RightClick method:
Selected = 0
Selected = THIS.ShortcutMenuAdd()
DO CASE
	CASE Selected = 1
		THIS.Copytoclipboard()
	CASE Selected = 3					&& user selected "Disassociate from wound"
		REPLACE WOUNDID WITH 0
		TABLEUPDATE()
		SELECT(nOldWorkArea)

	CASE Selected = 5
		DO FORM PictureProperties WITH THIS.nImageid
		
ENDCASE
ShortcutMenuAdd():
Result = 0
DEFINE POPUP mnuShortCut SHORTCUT RELATIVE FROM MROW(),MCOL()
DEFINE BAR 1 OF mnuShortCut PROMPT "\<Copy"
DEFINE BAR 2 OF mnuShortCut PROMPT "\-"
DEFINE BAR 3 OF mnuShortCut  PROMPT "\<Disassociate from wound"
DEFINE BAR 4 OF mnuShortCut PROMPT "\-"
DEFINE BAR 5 OF mnuShortCut  PROMPT "\<Properties"
ON SELECTION BAR 1 OF mnuShortCut ;
	STORE 1 TO Result
ON SELECTION BAR 3 OF mnuShortCut  ;
	STORE 3 TO Result
ON SELECTION BAR 5 OF mnuShortCut  ;
	STORE 5 TO Result
ACTIVATE POPUP mnuShortCut 

RETURN Result
Note that the CopyToClipboard() method is in the parent class, ImageA.

Any thoughts on out to inherit context menus from parent classes?

Jim
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform