method Link.InvokeContextMenu ([ContextMenu as Variant])
Invokes programmatically the link's default or customized context menu, and returns the identifier of the selected item.

TypeDescription
ContextMenu as Variant A String expression that defines the items to be displayed on the element's context-menu. If empty, the default context-menu for elements [ContextMenu(exContextMenuLink) property] is shown.
ReturnDescription
VariantA Long expression that indicates the identifier of the item being selected/clicked.
The InvokeContextMenu method invokes programmatically the link's default or customized context menu, and returns the identifier of the selected item. The ContextMenu(exContextMenuLink) property defines the default content-menu for links. The ActionContextMenu event notifies your application once an action occurs within the object's context menu. Use the AllowContextMenu property on exDisallow to disable default's context menu, when the user right clicks the element. The ContextMenuFont property retrieves or sets the context-menu's font. The Background(exContextMenuAppearance) property ( and related ) defines the control's context menu appearance.

By default, the link's context-menu shows as follows:

For instance, the InvokeContextMenu( "Item 1,Item 2,[sep],Check 1[chk],Check 2[chk]" ), generates the following screen shot:

For instance, the InvokeContextMenu( "Item 1,Item 2,Popup(Check 1[chk],Check 2[chk])" ), generates the following screen shot:

For instance, the InvokeContextMenu( "Calendar[id=20][img=0],MSChart[id=30],Record[id=40],Slider[id=50],Radio 1[id=100][typ=2][edit=],Radio 2[id=101][typ=2][edit=],Radio 3[id=102][typ=2][edit=],ComboBox[id=90]" ), generates the following screen shot:

The syntax for ContextMenu parameter in BNF notation is:

<ToString> ::= <ITEMS>
<ITEMS> ::= <ITEM>["("<ITEMS>")"][","<ITEMS>]
<ITEM> ::= <CAPTION>[<OPTIONS>]
<OPTIONS> ::= "["<OPTION>"]"["["<OPTIONS>"]"]
<OPTION> ::= <PROPERTY>["="<VALUE>]
<PROPERTY> ::= "img" | "himg" | "sep" | "id" | "typ" | "group" | "chk" | "button" | "align" | "spchk" | "show" | "rad" | "dis" | "showdis" | "bld" | "itl" | "stk" | "und" | "bg" | "fg" | "edittype" | "edit" | "mask" | "border" | "editwidth" | "captionwidth" | "height" | "grp" | "tfi" | "ttp" | "min" | "max" | "tick" | "freq" | "ticklabel" | "small" | "large" | "spin" | "ettp" | "float" | "close"

where the <CAPTION> is the HTML caption to be shown on the context menu item. The <VALUE> indicates the value of giving property.

The following samples invokes a custom-context menu for newly added element:

VBA (MS Access, Excell...)

With SwimLane1
	Debug.Print( .Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]") )
End With

VB6

With SwimLane1
	Debug.Print( .Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]") )
End With

VB.NET

With Exswimlane1
	Debug.Print( .Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]") )
End With

VB.NET for /COM

With AxSwimLane1
	Debug.Print( .Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]") )
End With

C++

/*
	Copy and paste the following directives to your header file as
	it defines the namespace 'EXSWIMLANELib' for the library: 'ExSwimLane 1.0 Control Library'

	#import <ExSwimLane.dll>
	using namespace EXSWIMLANELib;
*/
EXSWIMLANELib::ISwimLanePtr spSwimLane1 = GetDlgItem(IDC_SWIMLANE1)->GetControlUnknown();
OutputDebugStringW( _bstr_t(spSwimLane1->GetElements()->Add("Element",long(0),long(0))->InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]")) );

C++ Builder

OutputDebugString( PChar(SwimLane1->Elements->Add(TVariant("Element"),TVariant(0),TVariant(0))->InvokeContextMenu(TVariant("Item 1[id=1000],Item 2[id=2000]"))) );

C#

System.Diagnostics.Debug.Print( exswimlane1.Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]").ToString() );

JScript/JavaScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:AFA73FCE-6609-4062-AE6A-4BAD6D96A025" id="SwimLane1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
function Init()
{
	alert( SwimLane1.Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]") );
}
</SCRIPT>
</BODY>

VBScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:AFA73FCE-6609-4062-AE6A-4BAD6D96A025" id="SwimLane1"></OBJECT>

<SCRIPT LANGUAGE="VBScript">
Function Init()
	With SwimLane1
		alert( .Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]") )
	End With
End Function
</SCRIPT>
</BODY>

C# for /COM

System.Diagnostics.Debug.Print( axSwimLane1.Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]").ToString() );

X++ (Dynamics Ax 2009)

public void init()
{
	;

	super();

	print( exswimlane1.Elements().Add("Element",COMVariant::createFromInt(0),COMVariant::createFromInt(0)).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]") );
}

Delphi 8 (.NET only)

with AxSwimLane1 do
begin
	OutputDebugString( Elements.Add('Element',TObject(0),TObject(0)).InvokeContextMenu('Item 1[id=1000],Item 2[id=2000]') );
end

Delphi (standard)

with SwimLane1 do
begin
	OutputDebugString( Elements.Add('Element',OleVariant(0),OleVariant(0)).InvokeContextMenu('Item 1[id=1000],Item 2[id=2000]') );
end

VFP

with thisform.SwimLane1
	DEBUGOUT( .Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]") )
endwith

dBASE Plus

local oSwimLane

oSwimLane = form.EXSWIMLANEACTIVEXCONTROL1.nativeObject
? Str(oSwimLane.Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]")) 

XBasic (Alpha Five)

Dim oSwimLane as P

oSwimLane = topparent:CONTROL_ACTIVEX1.activex
? oSwimLane.Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]") 

Visual Objects


OutputDebugString(String2Psz( AsString(oDCOCX_Exontrol1:Elements:Add("Element",0,0):InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]")) ))

PowerBuilder

OleObject oSwimLane

oSwimLane = ole_1.Object
MessageBox("Information",string( String(oSwimLane.Elements.Add("Element",0,0).InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]")) ))

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Variant v
	Variant voElements
	Get ComElements to voElements
	Handle hoElements
	Get Create (RefClass(cComElements)) to hoElements
	Set pvComObject of hoElements to voElements
		Variant voElement
		Get ComAdd of hoElements "Element" 0 0 to voElement
		Handle hoElement
		Get Create (RefClass(cComElement)) to hoElement
		Set pvComObject of hoElement to voElement
			Get ComInvokeContextMenu of hoElement "Item 1[id=1000],Item 2[id=2000]" to v
		Send Destroy to hoElement
	Send Destroy to hoElements
	Showln v
End_Procedure

XBase++

#include "AppEvent.ch"
#include "ActiveX.ch"

PROCEDURE Main
 	LOCAL oForm
	LOCAL nEvent := 0, mp1 := NIL, mp2 := NIL, oXbp := NIL
	LOCAL oSwimLane

	oForm := XbpDialog():new( AppDesktop() )
	oForm:drawingArea:clipChildren := .T.
	oForm:create( ,,{100,100}, {640,480},, .F. )
	oForm:close  := {|| PostAppEvent( xbeP_Quit )}

	oSwimLane := XbpActiveXControl():new( oForm:drawingArea )
	oSwimLane:CLSID  := "Exontrol.SwimLane.1" /*{AFA73FCE-6609-4062-AE6A-4BAD6D96A025}*/
	oSwimLane:create(,, {10,60},{610,370} )

		DevOut( Transform(oSwimLane:Elements:Add("Element",0,0):InvokeContextMenu("Item 1[id=1000],Item 2[id=2000]"),"") )

	oForm:Show()
	DO WHILE nEvent != xbeP_Quit
		nEvent := AppEvent( @mp1, @mp2, @oXbp )
		oXbp:handleEvent( nEvent, mp1, mp2 )
	ENDDO 
RETURN