exmenu - sample code

How can I add a popup or a submenu?

VBA (MS Access, Excell...)

With ExMenu1
	With .Items.Add("Popup",2).SubMenu
		.Add "Item 1"
		.Add "Item 2"
	End With
	.Refresh 
End With

VB6

With ExMenu1
	With .Items.Add("Popup",2).SubMenu
		.Add "Item 1"
		.Add "Item 2"
	End With
	.Refresh 
End With

VB.NET

With Exmenu1
	With .Items.Add("Popup",2).SubMenu
		.Add("Item 1")
		.Add("Item 2")
	End With
	.Refresh()
End With

VB.NET for /COM

With AxExMenu1
	With .Items.Add("Popup",2).SubMenu
		.Add("Item 1")
		.Add("Item 2")
	End With
	.Refresh()
End With

C++

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

	#import <ExMenu.dll>
	using namespace EXMENULib;
*/
EXMENULib::IExMenuPtr spExMenu1 = GetDlgItem(IDC_EXMENU1)->GetControlUnknown();
EXMENULib::IMenuPtr var_Menu = spExMenu1->GetItems()->Add(L"Popup",long(2),vtMissing)->GetSubMenu();
	var_Menu->Add(L"Item 1",vtMissing,vtMissing);
	var_Menu->Add(L"Item 2",vtMissing,vtMissing);
spExMenu1->Refresh();

C++ Builder

Exmenulib_tlb::IMenuPtr var_Menu = ExMenu1->Items->Add(L"Popup",TVariant(2),TNoParam())->SubMenu;
	var_Menu->Add(L"Item 1",TNoParam(),TNoParam());
	var_Menu->Add(L"Item 2",TNoParam(),TNoParam());
ExMenu1->Refresh();

C#

exontrol.EXMENULib.exmenu var_Menu = exmenu1.Items.Add("Popup",2,null).SubMenu;
	var_Menu.Add("Item 1",null,null);
	var_Menu.Add("Item 2",null,null);
exmenu1.Refresh();

JavaScript

<OBJECT classid="clsid:7BE68958-94A9-4BCF-B556-8B31738F6FC2" id="ExMenu1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
	var var_Menu = ExMenu1.Items.Add("Popup",2,null).SubMenu;
		var_Menu.Add("Item 1",null,null);
		var_Menu.Add("Item 2",null,null);
	ExMenu1.Refresh();
</SCRIPT>

C# for /COM

EXMENULib.Menu var_Menu = axExMenu1.Items.Add("Popup",2,null).SubMenu;
	var_Menu.Add("Item 1",null,null);
	var_Menu.Add("Item 2",null,null);
axExMenu1.Refresh();

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_Menu,com_item;
	anytype var_Menu,var_item;
	;

	super();

	var_item = COM::createFromObject(exmenu1.Items()).Add("Popup",COMVariant::createFromInt(2)); com_item = var_item;
	var_Menu = com_item.SubMenu(); com_Menu = var_Menu;
		com_Menu.Add("Item 1");
		com_Menu.Add("Item 2");
	exmenu1.Refresh();
}

Delphi 8 (.NET only)

with AxExMenu1 do
begin
	with Items.Add('Popup',TObject(2),Nil).SubMenu do
	begin
		Add('Item 1',Nil,Nil);
		Add('Item 2',Nil,Nil);
	end;
	Refresh();
end

Delphi (standard)

with ExMenu1 do
begin
	with Items.Add('Popup',OleVariant(2),Null).SubMenu do
	begin
		Add('Item 1',Null,Null);
		Add('Item 2',Null,Null);
	end;
	Refresh();
end

VFP

with thisform.ExMenu1
	with .Items.Add("Popup",2).SubMenu
		.Add("Item 1")
		.Add("Item 2")
	endwith
	.Refresh
endwith

dBASE Plus

local oExMenu,var_Menu

oExMenu = form.Activex1.nativeObject
var_Menu = oExMenu.Items.Add("Popup",2).SubMenu
	var_Menu.Add("Item 1")
	var_Menu.Add("Item 2")
oExMenu.Refresh()

XBasic (Alpha Five)

Dim oExMenu as P
Dim var_Menu as P

oExMenu = topparent:CONTROL_ACTIVEX1.activex
var_Menu = oExMenu.Items.Add("Popup",2).SubMenu
	var_Menu.Add("Item 1")
	var_Menu.Add("Item 2")
oExMenu.Refresh()

Visual Objects

local var_Menu as IMenu

var_Menu := oDCOCX_Exontrol1:Items:Add("Popup",2,nil):SubMenu
	var_Menu:Add("Item 1",nil,nil)
	var_Menu:Add("Item 2",nil,nil)
oDCOCX_Exontrol1:Refresh()

PowerBuilder

OleObject oExMenu,var_Menu

oExMenu = ole_1.Object
var_Menu = oExMenu.Items.Add("Popup",2).SubMenu
	var_Menu.Add("Item 1")
	var_Menu.Add("Item 2")
oExMenu.Refresh()

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Variant voMenu
	Get ComItems to voMenu
	Handle hoMenu
	Get Create (RefClass(cComMenu)) to hoMenu
	Set pvComObject of hoMenu to voMenu
		Variant voitem
		Get ComAdd of hoMenu "Popup" 2 Nothing to voitem
		Handle hoitem
		Get Create (RefClass(cComitem)) to hoitem
		Set pvComObject of hoitem to voitem
			Variant voMenu1
			Get ComSubMenu of hoitem to voMenu1
			Handle hoMenu1
			Get Create (RefClass(cComMenu)) to hoMenu1
			Set pvComObject of hoMenu1 to voMenu1
				Get ComAdd of hoMenu1 "Item 1" Nothing Nothing to Nothing
				Get ComAdd of hoMenu1 "Item 2" Nothing Nothing to Nothing
			Send Destroy to hoMenu1
		Send Destroy to hoitem
	Send Destroy to hoMenu
	Send ComRefresh
End_Procedure

XBase++

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

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

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

	oExMenu := XbpActiveXControl():new( oForm:drawingArea )
	oExMenu:CLSID  := "Exontrol.ExMenu.1" /*{7BE68958-94A9-4BCF-B556-8B31738F6FC2}*/
	oExMenu:create(,, {10,60},{610,370} )

		oMenu := oExMenu:Items():Add("Popup",2):SubMenu()
			oMenu:Add("Item 1")
			oMenu:Add("Item 2")
		oExMenu:Refresh()

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