method ExContextMenu.Select ([Flags as Variant], [X as Variant], [Y as Variant])
Displays the shortcut menu at the specified location and tracks the selection of items on the menu.

TypeDescription
Flags as Variant A Long expression that indicates the alignment of the context menu relative to the giving X and Y parameters. If missing, the 0 is used, so the menu's top-left corner is aligned to X, Y coordinates. 

The Flags parameter can be a combination of the following values:

Use one of the following flags to specify how the function positions the shortcut menu horizontally:

  • 0    Positions the shortcut menu so that its left side is aligned with the coordinate specified by the x parameter.
  • 4    Centers the shortcut menu horizontally relative to the coordinate specified by the x parameter.
  • 8    Positions the shortcut menu so that its right side is aligned with the coordinate specified by the x parameter

Use one of the following flags to specify how the function positions the shortcut menu vertically:

  • 0    Positions the shortcut menu so that its top side is aligned with the coordinate specified by the y parameter
  • 16 Centers the shortcut menu vertically relative to the coordinate specified by the y parameter
  • 32 Positions the shortcut menu so that its bottom side is aligned with the coordinate specified by the y parameter

For instance, the 4 + 32 indicates that the menu is horizontally centered relative to x, and vertically it under the y coorindate.

X as Variant If missing or -1, the current cursor position is used, else it should indicate the X position to show the context menu, in screen coordinates.
Y as Variant If missing or -1, the current cursor position is used, else it should indicate the Y position to show the context menu, in screen coordinates.
ReturnDescription
LongA Long expression that specifies the identifier of the Item being clicked. A zero(0) value indicates that the user makes no selection, or no item has been clicked. A value different than zero indicates the item with the specified ID.  You can use the Item property of the control to get the associated Item object based on this identifier.
The Select property shows the context menu, and waits for the user to make the selection. The Select method displays nothing, if the Items collection is empty. The Select property returns the identifier of the item being clicked. If no item has been clicked ( or the user clicked outside of the context menu ), the Select property returns 0. The Items property gives accesses to the Items collection of the control, so you can add, remove or update the items to be displayed. The Add method adds a new item to the Items collection. The ToString property loads or saves the control items from a string. 

In case your context menu displays check-boxes, radio buttons, or items with Edit fields inside, you can use the GetChecked property gets a collection of checked items. The GetUnchecked property gets a collection of checked items. The GetRadio method gets a safe array with the radio-items being checked within a radio group. Also, you can use the Get method to retrieve a collection of Item objects based on your criteria. The control fires the SelectItem event when the user clicks an item.

The following samples show how to create the context menu, add a few items and call the Select method:

VB6, VBA (MS Access, Excell...), VB.NET for /COM

With Pivot1
	With CreateObject("Exontrol.ContextMenu")
		.Items.ToString = "Item A,Item B,Item C"
		Debug.Print( .Select() )
	End With
End With

VB.NET

With Expivot1
	' Add 'exontrol.excontextmenu.dll' reference to your project.
	With New exontrol.EXCONTEXTMENULib.excontextmenu()
		.Items.ToString = "Item A,Item B,Item C"
		Debug.Print( .Select() )
	End With
End With

C++

	/*
		Includes the definition for CreateObject function like follows:
		#include <comdef.h>
		IUnknownPtr CreateObject( BSTR Object )
		{
			IUnknownPtr spResult;
			spResult.CreateInstance( Object );
			return spResult;
		};
	*/
	/*
		Copy and paste the following directives to your header file as
		it defines the namespace 'EXCONTEXTMENULib' for the library: 'ExContextMenu 1.0 Type Library'
		#import <ExContextMenu.dll>
		using namespace EXCONTEXTMENULib;
	*/
	EXCONTEXTMENULib::IExContextMenuPtr var_ExContextMenu = ::CreateObject(L"Exontrol.ContextMenu");
		var_ExContextMenu->GetItems()->PutToString(L"Item A,Item B,Item C");
		OutputDebugStringW( _bstr_t(var_ExContextMenu->Select(vtMissing,vtMissing,vtMissing)) );

C++ Builder

/*
	Select the Component\Import Component...\Import a Type Library,
	to import the following Type Library:
		ExContextMenu 1.0 Type Library
	TypeLib: e:\Exontrol\ExContextMenu\project\Site\ExContextMenu.dll
	to define the namespace: Excontextmenulib_tlb
*/
//#include "EXCONTEXTMENULIB_TLB.h"
Excontextmenulib_tlb::IExContextMenuPtr var_ExContextMenu = Variant::CreateObject(L"Exontrol.ContextMenu");
	var_ExContextMenu->Items->ToString = L"Item A,Item B,Item C";
	OutputDebugString( PChar(var_ExContextMenu->Select(TNoParam(),TNoParam(),TNoParam())) );

C#

// Add 'exontrol.excontextmenu.dll' reference to your project.
exontrol.EXCONTEXTMENULib.excontextmenu var_ExContextMenu = new exontrol.EXCONTEXTMENULib.excontextmenu();
	var_ExContextMenu.Items.ToString = "Item A,Item B,Item C";
	System.Diagnostics.Debug.Print( var_ExContextMenu.Select(null,null,null).ToString() );

X++ (Dynamics Ax 2009)

	COM com_ExContextMenu,com_Items;
	anytype var_ExContextMenu,var_Items;
	;
	// Add 'excontextmenu.dll' reference to your project.
	// Add 'ExContextMenu 1.0 Type Library' reference to your project.
	var_ExContextMenu = COM::createFromObject(new EXCONTEXTMENULib.excontextmenu()); com_ExContextMenu = var_ExContextMenu;
		var_Items = COM::createFromObject(com_ExContextMenu.Items()); com_Items = var_Items;
		com_Items.ToString("Item A,Item B,Item C");
		print( com_ExContextMenu.Select() )

Delphi 8 (.NET only)

with (ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.ContextMenu')) as EXCONTEXTMENULib.ExContextMenu) do
begin
	Items.ToString := 'Item A,Item B,Item C';
	OutputDebugString( Select(Nil,Nil,Nil) );
end;

Delphi (standard)

with (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.ContextMenu'))) as EXCONTEXTMENULib_TLB.ExContextMenu) do
begin
	Items.ToString := 'Item A,Item B,Item C';
	OutputDebugString( Select(Null,Null,Null) );
end;

VFP

with CreateObject("Exontrol.ContextMenu")
	.Items.ToString = "Item A,Item B,Item C"
	DEBUGOUT( .Select() )
endwith