This sample illustrates an alternative way to create shortcut menus.
The shortcut menus in the Display Shortcut Menus sample were created in the Menu Designer. The advantages of using the Menu Designer are ease of design, the ability to create cascading menus, and simple integration on a form. With the Menu Designer, however, you need a separate .mnx, .mnt, and .mpr file for each shortcut menu. If you make a change, you need to generate and compile the menu code again.
The dynamic shortcut menu engine is a custom class that you can add to any form: menulib in ...\Samples\Classes\Utility.vcx. The ShowMenu method of this class defines a menu and displays it at the MousePointer location as determined by the MROW(В ) and MCOL(В ) functions.
In the RightClick event of the objects you want to create a shortcut menu for, do the following:
Create an array with the shortcut menu items.
Pass the array to the ShowMenu method of the menulib class.
Process the user choice by checking the BAR(В ) value.
For example, the following code is associated with the RightClick event of the form:
LOCAL laMenu laMenu="" laMenu="\<Center" laMenu="\<Font..." laMenu="\<Minimize" laMenu="\-" laMenu="E\<xit" THISFORM.oMenuShortcut.ShowMenu(@laMenu) DO CASE CASE BAR()=1 THISFORM.AutoCenter=.T. CASE BAR()=2 THISFORM.SetFont CASE BAR()=3 THISFORM.WindowState=1 CASE BAR()=5 THISFORM.Release ENDCASE