Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Context Menus
Message
From
20/08/2002 03:58:05
 
 
To
19/08/2002 14:24:48
John Tomblin
Service Station Systems, Inc.
San Jose, California, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
00691160
Message ID:
00691357
Views:
17
John,

The FFC classes contain a handy shortcut menu class which allows you to dynamically define shortcut menus without the need to create a MNX/MPR file. Personally, I find this a lot easier to use and maintain. Here's a simple menu sample that demonstrates how to use the FFC class. You should add the code below to your object's rightclick(). Note that there are two ways to define the menu actions. Method 2 adds more code but is much more flexible and allows you to reference the current object (ThisForm, This, etc.).
LOCAL loShortcut

loShortcut = NEWOBJECT("_shortcutmenu", HOME()+"\ffc\_menu.vcx")

WITH loShortcut

*-- create dynamic menu

*-- parameters for addMenuBar():
*--   tcPrompt
*--   tcOnSelection
*--   tcClauses (e.g. Picture clause in VFP7)
*--   tnElementNumber
*--   tlMark
*--   tlDisabled
*--   tlBold

*-- method 1:
*-- pass OnSelection parameter
.addMenuBar("MenuBar 1", "WAIT WINDOW NOWAIT 'MenuBar 1'", "", 1, .t., .f., .f.)
.addMenuBar("MenuBar 2", "WAIT WINDOW NOWAIT 'MenuBar 2'", "", 2, .f., .t., .f.)
.addMenuSeparator(3)
.addMenuBar("MenuBar 4", "WAIT WINDOW NOWAIT 'MenuBar 4'", "", 4, .f., .f., .t.)
.addMenuBar("MenuBar 5", "WAIT WINDOW NOWAIT 'MenuBar 5'", " PICTURE 'yourBmp.bmp'", 5, .f., .f., .f.) && requires VFP7()

*-- Method 1 works well for simple commands. If you need to 
*-- run several lines of code you might want to use the following approach:

.addMenuBar("MenuBar 1", "", "", 1, .t., .f., .f.)
.addMenuBar("MenuBar 2", "", "", 2, .f., .t., .f.)
.addMenuSeparator(3)
.addMenuBar("MenuBar 4", "", "", 4, .f., .f., .t.)
.addMenuBar("MenuBar 5", "", " PICTURE 'yourBmp.bmp'", 5, .f., .f., .f.) && requires VFP7

DO CASE
   CASE BAR() = 1
      *-- your code goes here.
      WAIT WINDOW 'MenuBar 1a'
      WAIT WINDOW 'MenuBar 1b'
   CASE BAR() = 2
      *-- your code goes here.
      WAIT WINDOW 'MenuBar 2a'
      WAIT WINDOW 'MenuBar 2b'
   CASE BAR() = 3
      *-- your code goes here.
      *-- your code goes here.
      WAIT WINDOW 'MenuBar 3a'
      WAIT WINDOW 'MenuBar 3b'
   CASE BAR() = 4
      *-- your code goes here.
      *-- your code goes here.
      WAIT WINDOW 'MenuBar 4a'
      WAIT WINDOW 'MenuBar 4b'
   CASE BAR() = 5
      *-- your code goes here.
      *-- your code goes here.
      WAIT WINDOW 'MenuBar 5'
      WAIT WINDOW 'MenuBar 5b'
ENDCASE

ENDWITH
HTH
>Does anyone know a means for creating a right-click context menu in Foxpro.
Daniel
Previous
Reply
Map
View

Click here to load this message in the networking platform