extoolbarcrd - sample code

How can I add / display items with the toolbar?

VBA (MS Access, Excell...)

' Select event - Notifies once the user clicks the item.
Private Sub ToolBarCRD1_Select(ByVal ID As Variant,ByVal SelectedID As Variant)
	With ToolBarCRD1
		Debug.Print( "Select" )
		Debug.Print( .Item(ID).Caption )
	End With
End Sub

With ToolBarCRD1
	.Format = "1,-1,2,3"
	.Item(1).Caption = "Exit"
	.Item(2).Caption = "Item <b>A"
	.Item(3).Caption = "Item <b>B"
End With

VB6

' Select event - Notifies once the user clicks the item.
Private Sub ToolBarCRD1_Select(ByVal ID As Variant,ByVal SelectedID As Variant)
	With ToolBarCRD1
		Debug.Print( "Select" )
		Debug.Print( .Item(ID).Caption )
	End With
End Sub

With ToolBarCRD1
	.Format = "1,-1,2,3"
	.Item(1).Caption = "Exit"
	.Item(2).Caption = "Item <b>A"
	.Item(3).Caption = "Item <b>B"
End With

VB.NET

' Select event - Notifies once the user clicks the item.
Private Sub Extoolbarcrd1_Select(ByVal sender As System.Object,ByVal ID As Object,ByVal SelectedID As Object) Handles Extoolbarcrd1.Select
	With Extoolbarcrd1
		Debug.Print( "Select" )
		Debug.Print( .Item(ID).Caption )
	End With
End Sub

With Extoolbarcrd1
	.Format = "1,-1,2,3"
	.Item(1).Caption = "Exit"
	.Item(2).Caption = "Item <b>A"
	.Item(3).Caption = "Item <b>B"
End With

VB.NET for /COM

' Select event - Notifies once the user clicks the item.
Private Sub AxToolBarCRD1_Select(ByVal sender As System.Object, ByVal e As AxEXTOOLBARCRDLib._IToolBarCRDEvents_SelectEvent) Handles AxToolBarCRD1.Select
	With AxToolBarCRD1
		Debug.Print( "Select" )
		Debug.Print( .get_Item(e.iD).Caption )
	End With
End Sub

With AxToolBarCRD1
	.Format = "1,-1,2,3"
	.get_Item(1).Caption = "Exit"
	.get_Item(2).Caption = "Item <b>A"
	.get_Item(3).Caption = "Item <b>B"
End With

C++

// Select event - Notifies once the user clicks the item.
void OnSelectToolBarCRD1(VARIANT   ID,VARIANT   SelectedID)
{
	/*
		Copy and paste the following directives to your header file as
		it defines the namespace 'EXTOOLBARCRDLib' for the library: 'ExToolBar.CRD 1.0 Control Library'
		#import <ExToolBar.CRD.dll>
		using namespace EXTOOLBARCRDLib;
	*/
	EXTOOLBARCRDLib::IToolBarCRDPtr spToolBarCRD1 = GetDlgItem(IDC_TOOLBARCRD1)->GetControlUnknown();
	OutputDebugStringW( L"Select" );
	OutputDebugStringW( spToolBarCRD1->GetItem(ID)->GetCaption() );
}

EXTOOLBARCRDLib::IToolBarCRDPtr spToolBarCRD1 = GetDlgItem(IDC_TOOLBARCRD1)->GetControlUnknown();
spToolBarCRD1->PutFormat(L"1,-1,2,3");
spToolBarCRD1->GetItem(long(1))->PutCaption(L"Exit");
spToolBarCRD1->GetItem(long(2))->PutCaption(L"Item <b>A");
spToolBarCRD1->GetItem(long(3))->PutCaption(L"Item <b>B");

C++ Builder

// Select event - Notifies once the user clicks the item.
void __fastcall TForm1::ToolBarCRD1Select(TObject *Sender,Variant   ID,Variant   SelectedID)
{
	OutputDebugString( L"Select" );
	OutputDebugString( ToolBarCRD1->Item[TVariant(ID)]->Caption );
}

ToolBarCRD1->Format = L"1,-1,2,3";
ToolBarCRD1->Item[TVariant(1)]->Caption = L"Exit";
ToolBarCRD1->Item[TVariant(2)]->Caption = L"Item <b>A";
ToolBarCRD1->Item[TVariant(3)]->Caption = L"Item <b>B";

C#

// Select event - Notifies once the user clicks the item.
private void extoolbarcrd1_Select(object sender,object   ID,object   SelectedID)
{
	System.Diagnostics.Debug.Print( "Select" );
	System.Diagnostics.Debug.Print( extoolbarcrd1[ID].Caption );
}
//this.extoolbarcrd1.Select += new exontrol.EXTOOLBARCRDLib.exg2antt.SelectEventHandler(this.extoolbarcrd1_Select);

extoolbarcrd1.Format = "1,-1,2,3";
extoolbarcrd1[1].Caption = "Exit";
extoolbarcrd1[2].Caption = "Item <b>A";
extoolbarcrd1[3].Caption = "Item <b>B";

JScript/JavaScript

<BODY onload="Init()">
<SCRIPT FOR="ToolBarCRD1" EVENT="Select(ID,SelectedID)" LANGUAGE="JScript">
	alert( "Select" );
	alert( ToolBarCRD1.Item(ID).Caption );
</SCRIPT>

<OBJECT CLASSID="clsid:DD586AE6-F2A0-4308-8F34-8016B16F000E" id="ToolBarCRD1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
function Init()
{
	ToolBarCRD1.Format = "1,-1,2,3";
	ToolBarCRD1.Item(1).Caption = "Exit";
	ToolBarCRD1.Item(2).Caption = "Item <b>A";
	ToolBarCRD1.Item(3).Caption = "Item <b>B";
}
</SCRIPT>
</BODY>

VBScript

<BODY onload="Init()">
<SCRIPT LANGUAGE="VBScript">
Function ToolBarCRD1_Select(ID,SelectedID)
	With ToolBarCRD1
		alert( "Select" )
		alert( .Item(ID).Caption )
	End With
End Function
</SCRIPT>

<OBJECT CLASSID="clsid:DD586AE6-F2A0-4308-8F34-8016B16F000E" id="ToolBarCRD1"></OBJECT>

<SCRIPT LANGUAGE="VBScript">
Function Init()
	With ToolBarCRD1
		.Format = "1,-1,2,3"
		.Item(1).Caption = "Exit"
		.Item(2).Caption = "Item <b>A"
		.Item(3).Caption = "Item <b>B"
	End With
End Function
</SCRIPT>
</BODY>

C# for /COM

// Select event - Notifies once the user clicks the item.
private void axToolBarCRD1_Select(object sender, AxEXTOOLBARCRDLib._IToolBarCRDEvents_SelectEvent e)
{
	System.Diagnostics.Debug.Print( "Select" );
	System.Diagnostics.Debug.Print( axToolBarCRD1[e.iD].Caption );
}
//this.axToolBarCRD1.Select += new AxEXTOOLBARCRDLib._IToolBarCRDEvents_SelectEventHandler(this.axToolBarCRD1_Select);

axToolBarCRD1.Format = "1,-1,2,3";
axToolBarCRD1[1].Caption = "Exit";
axToolBarCRD1[2].Caption = "Item <b>A";
axToolBarCRD1[3].Caption = "Item <b>B";

X++ (Dynamics Ax 2009)

// Select event - Notifies once the user clicks the item.
void onEvent_Select(COMVariant   _ID,COMVariant   _SelectedID)
{
	;
	print( "Select" );
	print( extoolbarcrd1.Item(_ID).Caption() );
}

public void init()
{
	COM com_Item;
	anytype var_Item;
	;

	super();

	extoolbarcrd1.Format("1,-1,2,3");
	var_Item = COM::createFromObject(extoolbarcrd1.Item(COMVariant::createFromInt(1))); com_Item = var_Item;
	com_Item.Caption("Exit");
	var_Item = COM::createFromObject(extoolbarcrd1.Item(COMVariant::createFromInt(2))); com_Item = var_Item;
	com_Item.Caption("Item <b>A");
	var_Item = COM::createFromObject(extoolbarcrd1.Item(COMVariant::createFromInt(3))); com_Item = var_Item;
	com_Item.Caption("Item <b>B");
}

Delphi 8 (.NET only)

// Select event - Notifies once the user clicks the item.
procedure TWinForm1.AxToolBarCRD1_Select(sender: System.Object; e: AxEXTOOLBARCRDLib._IToolBarCRDEvents_SelectEvent);
begin
	with AxToolBarCRD1 do
	begin
		OutputDebugString( 'Select' );
		OutputDebugString( get_Item(TObject(e.iD)).Caption );
	end
end;

with AxToolBarCRD1 do
begin
	Format := '1,-1,2,3';
	get_Item(TObject(1)).Caption := 'Exit';
	get_Item(TObject(2)).Caption := 'Item <b>A';
	get_Item(TObject(3)).Caption := 'Item <b>B';
end

Delphi (standard)

// Select event - Notifies once the user clicks the item.
procedure TForm1.ToolBarCRD1Select(ASender: TObject; ID : OleVariant;SelectedID : OleVariant);
begin
	with ToolBarCRD1 do
	begin
		OutputDebugString( 'Select' );
		OutputDebugString( Item[OleVariant(ID)].Caption );
	end
end;

with ToolBarCRD1 do
begin
	Format := '1,-1,2,3';
	Item[OleVariant(1)].Caption := 'Exit';
	Item[OleVariant(2)].Caption := 'Item <b>A';
	Item[OleVariant(3)].Caption := 'Item <b>B';
end

VFP

*** Select event - Notifies once the user clicks the item. ***
LPARAMETERS ID,SelectedID
	with thisform.ToolBarCRD1
		DEBUGOUT( "Select" )
		DEBUGOUT( .Item(ID).Caption )
	endwith

with thisform.ToolBarCRD1
	.Format = "1,-1,2,3"
	.Item(1).Caption = "Exit"
	.Item(2).Caption = "Item <b>A"
	.Item(3).Caption = "Item <b>B"
endwith

dBASE Plus

/*
with (this.EXTOOLBAR_CRDACTIVEXCONTROL1.nativeObject)
	Select = class::nativeObject_Select
endwith
*/
// Notifies once the user clicks the item.
function nativeObject_Select(ID,SelectedID)
	oToolBarCRD = form.EXTOOLBAR_CRDACTIVEXCONTROL1.nativeObject
	? "Select" 
	? oToolBarCRD.Item(ID).Caption 
return

local oToolBarCRD,var_Item,var_Item1,var_Item2

oToolBarCRD = form.EXTOOLBAR_CRDACTIVEXCONTROL1.nativeObject
oToolBarCRD.Format = "1,-1,2,3"
// oToolBarCRD.Item(1).Caption = "Exit"
var_Item = oToolBarCRD.Item(1)
with (oToolBarCRD)
	TemplateDef = [dim var_Item]
	TemplateDef = var_Item
	Template = [var_Item.Caption = "Exit"]
endwith
// oToolBarCRD.Item(2).Caption = "Item <b>A"
var_Item1 = oToolBarCRD.Item(2)
with (oToolBarCRD)
	TemplateDef = [dim var_Item1]
	TemplateDef = var_Item1
	Template = [var_Item1.Caption = "Item <b>A"]
endwith
// oToolBarCRD.Item(3).Caption = "Item <b>B"
var_Item2 = oToolBarCRD.Item(3)
with (oToolBarCRD)
	TemplateDef = [dim var_Item2]
	TemplateDef = var_Item2
	Template = [var_Item2.Caption = "Item <b>B"]
endwith

XBasic (Alpha Five)

' Notifies once the user clicks the item.
function Select as v (ID  as  A,SelectedID  as  A)
	oToolBarCRD = topparent:CONTROL_ACTIVEX1.activex
	? "Select" 
	? oToolBarCRD.Item(ID).Caption 
end function

Dim oToolBarCRD as P
Dim var_Item as local
Dim var_Item1 as local
Dim var_Item2 as local

oToolBarCRD = topparent:CONTROL_ACTIVEX1.activex
oToolBarCRD.Format = "1,-1,2,3"
' oToolBarCRD.Item(1).Caption = "Exit"
var_Item = oToolBarCRD.Item(1)
oToolBarCRD.TemplateDef = "dim var_Item"
oToolBarCRD.TemplateDef = var_Item
oToolBarCRD.Template = "var_Item.Caption = `Exit`"

' oToolBarCRD.Item(2).Caption = "Item <b>A"
var_Item1 = oToolBarCRD.Item(2)
oToolBarCRD.TemplateDef = "dim var_Item1"
oToolBarCRD.TemplateDef = var_Item1
oToolBarCRD.Template = "var_Item1.Caption = `Item <b>A`"

' oToolBarCRD.Item(3).Caption = "Item <b>B"
var_Item2 = oToolBarCRD.Item(3)
oToolBarCRD.TemplateDef = "dim var_Item2"
oToolBarCRD.TemplateDef = var_Item2
oToolBarCRD.Template = "var_Item2.Caption = `Item <b>B`"


Visual Objects

METHOD OCX_Exontrol1Select(ID,SelectedID) CLASS MainDialog
	// Select event - Notifies once the user clicks the item.
	OutputDebugString(String2Psz( "Select" ))
	OutputDebugString(String2Psz( oDCOCX_Exontrol1:[Item,ID]:Caption ))
RETURN NIL


oDCOCX_Exontrol1:Format := "1,-1,2,3"
oDCOCX_Exontrol1:[Item,1]:Caption := "Exit"
oDCOCX_Exontrol1:[Item,2]:Caption := "Item <b>A"
oDCOCX_Exontrol1:[Item,3]:Caption := "Item <b>B"

PowerBuilder

/*begin event Select(any  ID,any  SelectedID) - Notifies once the user clicks the item.*/
/*
	oToolBarCRD = ole_1.Object
	MessageBox("Information",string( "Select" ))
	MessageBox("Information",string( oToolBarCRD.Item(ID).Caption ))
*/
/*end event Select*/

OleObject oToolBarCRD

oToolBarCRD = ole_1.Object
oToolBarCRD.Format = "1,-1,2,3"
oToolBarCRD.Item(1).Caption = "Exit"
oToolBarCRD.Item(2).Caption = "Item <b>A"
oToolBarCRD.Item(3).Caption = "Item <b>B"

Visual DataFlex

// Notifies once the user clicks the item.
Procedure OnComSelect Variant   llID Variant   llSelectedID
	Forward Send OnComSelect llID llSelectedID
	Variant v
	Variant voItem
	Get ComItem llID to voItem
	Handle hoItem
	Get Create (RefClass(cComItem)) to hoItem
	Set pvComObject of hoItem to voItem
		Get ComCaption of hoItem to v
	Send Destroy to hoItem
	Showln "Select" v
End_Procedure

Procedure OnCreate
	Forward Send OnCreate
	Set ComFormat to "1,-1,2,3"
	Variant voItem1
	Get ComItem 1 to voItem1
	Handle hoItem1
	Get Create (RefClass(cComItem)) to hoItem1
	Set pvComObject of hoItem1 to voItem1
		Set ComCaption of hoItem1 to "Exit"
	Send Destroy to hoItem1
	Variant voItem2
	Get ComItem 2 to voItem2
	Handle hoItem2
	Get Create (RefClass(cComItem)) to hoItem2
	Set pvComObject of hoItem2 to voItem2
		Set ComCaption of hoItem2 to "Item <b>A"
	Send Destroy to hoItem2
	Variant voItem3
	Get ComItem 3 to voItem3
	Handle hoItem3
	Get Create (RefClass(cComItem)) to hoItem3
	Set pvComObject of hoItem3 to voItem3
		Set ComCaption of hoItem3 to "Item <b>B"
	Send Destroy to hoItem3
End_Procedure

XBase++

PROCEDURE OnSelect(oToolBarCRD,ID,SelectedID)
	DevOut( "Select" )
	DevOut( oToolBarCRD:Item(ID):Caption() )
RETURN

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

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

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

	oToolBarCRD := XbpActiveXControl():new( oForm:drawingArea )
	oToolBarCRD:CLSID  := "Exontrol.ToolBar.CRD.1" /*{DD586AE6-F2A0-4308-8F34-8016B16F000E}*/
	oToolBarCRD:create(,, {10,60},{610,370} )

		oToolBarCRD:Select := {|ID,SelectedID| OnSelect(oToolBarCRD,ID,SelectedID)} /*Notifies once the user clicks the item.*/

		oToolBarCRD:Format := "1,-1,2,3"
		oToolBarCRD:Item(1):Caption := "Exit"
		oToolBarCRD:Item(2):Caption := "Item <b>A"
		oToolBarCRD:Item(3):Caption := "Item <b>B"

	oForm:Show()
	DO WHILE nEvent != xbeP_Quit
		nEvent := AppEvent( @mp1, @mp2, @oXbp )
		oXbp:handleEvent( nEvent, mp1, mp2 )
	ENDDO 
RETURN
Copyright 1999-2017 Exontrol. All rights reserved.