Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Right click context menu
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire de menu & Menus
Divers
Thread ID:
00394346
Message ID:
00394359
Vues:
12
>Hello,
>
>How can I create a context menu and show it on right click? I did not find where to look it up in the help.

What we have here (which may be different from others) is we have this built into our application object. So lets say we have a text box. Our base class for a text box has code in the rightclick event that looks like the following:
* Display a right-click menu.

This.ShowMenu()
In the ShowMenu method of the text box we have the following code:
* Display a shortcut menu.

local loObject

* Define a reference to this object in case the action for a bar is to call a
* method of this object, which can't be done using "This.Method" ("This" isn't
* applicable in a menu). The action can be specified as "loObject.Method".

loObject = This

* Define the menu.

release popup SHORTCUT
define popup SHORTCUT shortcut from mrow(), mcol()
with This

* Populate it using a custom method.

     .ShortcutMenu()

* Use the hook object (if there is one) to do any further population of the
* menu.

     if type('.oHook') = 'O' and not isnull(.oHook) and ;
          pemstatus(.oHook, 'ShortcutMenu', 5)
          .oHook.ShortcutMenu()
     endif type('.oHook') = 'O' ...
endwith

* Activate the menu if necessary.

if cntbar('SHORTCUT') > 0
     activate popup SHORTCUT
endif cntbar('SHORTCUT') > 0
release popup SHORTCUT
So then all a programmer has to do is put code in the ShortCutMenu method to create any rightmouse click menu they wish. Example:
* Populate the shortcut menu.
define bar 1 of SHORTCUT prompt 'View Lot Datacard: '+lotdata.lotnumber
define bar 2 of SHORTCUT prompt 'Replace Master Manufacture Date With Lot Date Completed: '+DTOC(lotdata.lotdatecmp)
IF 'LOTDATECMP' $ UPPER(SET('ORDER'))
  define bar 3 of SHORTCUT prompt 'Set Order To Lot Number '
  define bar 4 of SHORTCUT prompt 'Set Order To FRN '
ELSE
  IF 'FRNFRN' $ UPPER(SET('ORDER'))
    define bar 3 of SHORTCUT prompt 'Set Order To Lot Number '
    define bar 4 of SHORTCUT prompt 'Set Order To Date Completed '
  ELSE
    define bar 3 of SHORTCUT prompt 'Set Order To Date Completed '
    define bar 4 of SHORTCUT prompt 'Set Order To FRN '
  ENDIF
ENDIF

on selection bar 1 of SHORTCUT _screen.ActiveForm.LotCardUtilities.ViewLotData(ALLTRIM(lotdata.lotnumber))
on selection bar 2 of SHORTCUT _screen.ActiveForm.C40pgAnalysis.Page2.C40cmdMoveLotDateCompleteToMfrDate.Click()
IF 'LOTDATECMP' $ UPPER(SET('ORDER'))
  on selection bar 3 of SHORTCUT _screen.ActiveForm.C40pgAnalysis.Page2.C40cmdToggleLotDataOrder.Click('LOTNUMBER')
  on selection bar 4 of SHORTCUT _screen.ActiveForm.C40pgAnalysis.Page2.C40cmdToggleLotDataOrder.Click('FRNFRN')
ELSE
  IF 'FRNFRN' $ UPPER(SET('ORDER'))
    on selection bar 3 of SHORTCUT _screen.ActiveForm.C40pgAnalysis.Page2.C40cmdToggleLotDataOrder.Click('LOTNUMBER')
    on selection bar 4 of SHORTCUT _screen.ActiveForm.C40pgAnalysis.Page2.C40cmdToggleLotDataOrder.Click('LOTDATECMP')
  ELSE
    on selection bar 3 of SHORTCUT _screen.ActiveForm.C40pgAnalysis.Page2.C40cmdToggleLotDataOrder.Click('LOTDATECMP')
    on selection bar 4 of SHORTCUT _screen.ActiveForm.C40pgAnalysis.Page2.C40cmdToggleLotDataOrder.Click('FRNFRN')
  ENDIF
ENDIF
I hope this help to get you started. Mostly all of our controls have this built into the application objects. So a text box or grid or list would have the same functionality.
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform