In the standard MAS 500 screens, there are Context sensitive menus in the transaction grids where user clicks the right button of the mouse and a popup is prompted to perform different functions.
User selects the options to perform different functions like ‘Add line’ to add a new line, ‘Insert Line’ to insert a line in the grid, etc.
Adding custom options in the context-sensitive menu will be useful to provide new menus like “Copy Line”, “Import/Export”, etc and writing logic for that options to perform the desired functions. Please refer the below screenshot.
Below we have provided instructions and a sample code to add a custom menu in the standard context-sensitive menus:
- User will need to add the code in the procedure ‘BindContextMenu’ which is called from Form Load event.
- Call a function ‘CMAppendContextMenu’ which will be called when we write the append code in the BindContextMenu procedure.
- After writing the code in the CMAppendContextMenu procedure the additional custom menu will be displayed in the menu list.
- To execute the logic which is to be called from the custom menu selected is to be written in a function ‘CMMenuSelected’.
Example:
- Adding Code in the Procedure BindContextMenu
.Bind “*Append”, Cstr (grdMain.hwnd)
Using “*Append” the function CMAppendContextMenu will be called when user clicks the right button of the mouse.
- Writing code in the function CMAppendContextMenu
If the above function is already present in the source code then you need to add the additional code in the above function.
If the function is not present in the source code then you have to write the function as follows:
Public Function CMAppendContextMenu(Ctl as Control, hmenu as Long) as Boolean
Ctl: The control that received the right mouse button down message.
Hmenu: A Long type. The menu handles of the popup menu.
Return Value A Boolean. Returns true if an item was appended to the menu. Returns False if nothing was appended to the menu.
Dim sCopy As String
sCopy = “&Copy”
Select Case True
Case ctl Is grdMain
lRow = glGridGetActiveRow (grdMain)
If lRow > 1 Then
AppendMenu hmenu, MF_ENABLED, 30003, sCopy
CMAppendContextMenu = True
End If
End Select
- Writing code in the function CMMenuSelected
If the above function is already present in the source code then you need to add the additional code in the above function.
If the function is not present in the source code then you have to write the function as follows:
Public Sub CMMenuSelected (ctl As Control, lTaskID As Long)
ctl: The control that received the right mouse button down message.
lTaskID: The Task ID of the selected task.
The above function is called when the custom menu is selected. You have to write the logic which is to be performed when the custom menu is selected.
Hope this helps.
In case of any assistance feel free to contact us at sage@greytrix.com.
About Us
Greytrix is a one stop solution provider for Sage ERP and Sage CRM needs. We provide complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.
Greytrix has some unique solutions of Sage 100 integration with Sage CRM, and Salesforce.com along with Sage 100 Migration from Sage 50 US, Sage Intacct, QuickBooks, Sage Business Vision and Sage Business Works. We also offer best-in-class Sage 100 customization and development services to Sage business partners, end users, and Sage PSG worldwide.
For more details on Sage 100 Services, please contact us at sage@greytrix.com. We will be glad to assist you.