exg2host - sample code

How can I disable AddNew?

VBA (MS Access, Excell...)

With G2Host1
	.DataSource("Items") = "C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb"
	.DataMember("Items") = "Employees"
	.DataField(0) = "Items"
	.HostReadOnly = 240 ' HostReadOnlyEnum.exHostAllowUpdate Or HostReadOnlyEnum.exHostAllowDelete
End With

VB6

With G2Host1
	.DataSource("Items") = "C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb"
	.DataMember("Items") = "Employees"
	.DataField(exItemsDataSource) = "Items"
	.HostReadOnly = HostReadOnlyEnum.exHostAllowUpdate Or HostReadOnlyEnum.exHostAllowDelete
End With

VB.NET

With Exg2host1
	.set_DataSource("Items","C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb")
	.set_DataMember("Items","Employees")
	.set_DataField(exontrol.EXG2HOSTLib.HostObjectFieldEnum.exItemsDataSource,"Items")
	.HostReadOnly = exontrol.EXG2HOSTLib.HostReadOnlyEnum.exHostAllowUpdate Or exontrol.EXG2HOSTLib.HostReadOnlyEnum.exHostAllowDelete
End With

VB.NET for /COM

With AxG2Host1
	.set_DataSource("Items","C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb")
	.set_DataMember("Items","Employees")
	.set_DataField(EXG2HOSTLib.HostObjectFieldEnum.exItemsDataSource,"Items")
	.HostReadOnly = EXG2HOSTLib.HostReadOnlyEnum.exHostAllowUpdate Or EXG2HOSTLib.HostReadOnlyEnum.exHostAllowDelete
End With

C++

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

	#import <ExG2Host.dll>
	using namespace EXG2HOSTLib;
*/
EXG2HOSTLib::IG2HostPtr spG2Host1 = GetDlgItem(IDC_G2HOST1)->GetControlUnknown();
spG2Host1->PutDataSource(L"Items","C:\\Program Files\\Exontrol\\ExG2Host\\Sample\\sample.accdb");
spG2Host1->PutDataMember(L"Items",L"Employees");
spG2Host1->PutDataField(EXG2HOSTLib::exItemsDataSource,L"Items");
spG2Host1->PutHostReadOnly(EXG2HOSTLib::HostReadOnlyEnum(EXG2HOSTLib::exHostAllowUpdate | EXG2HOSTLib::exHostAllowDelete));

C++ Builder

G2Host1->DataSource[L"Items"] = TVariant("C:\\Program Files\\Exontrol\\ExG2Host\\Sample\\sample.accdb");
G2Host1->DataMember[L"Items"] = L"Employees";
G2Host1->DataField[Exg2hostlib_tlb::HostObjectFieldEnum::exItemsDataSource] = L"Items";
G2Host1->HostReadOnly = Exg2hostlib_tlb::HostReadOnlyEnum::exHostAllowUpdate | Exg2hostlib_tlb::HostReadOnlyEnum::exHostAllowDelete;

C#

exg2host1.set_DataSource("Items","C:\\Program Files\\Exontrol\\ExG2Host\\Sample\\sample.accdb");
exg2host1.set_DataMember("Items","Employees");
exg2host1.set_DataField(exontrol.EXG2HOSTLib.HostObjectFieldEnum.exItemsDataSource,"Items");
exg2host1.HostReadOnly = exontrol.EXG2HOSTLib.HostReadOnlyEnum.exHostAllowUpdate | exontrol.EXG2HOSTLib.HostReadOnlyEnum.exHostAllowDelete;

JScript/JavaScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:DFE195F7-4F43-482A-A14B-0C97B032A5E1" id="G2Host1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
function Init()
{
	G2Host1.DataSource("Items") = "C:\\Program Files\\Exontrol\\ExG2Host\\Sample\\sample.accdb";
	G2Host1.DataMember("Items") = "Employees";
	G2Host1.DataField(0) = "Items";
	G2Host1.HostReadOnly = 240;
}
</SCRIPT>
</BODY>

VBScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:DFE195F7-4F43-482A-A14B-0C97B032A5E1" id="G2Host1"></OBJECT>

<SCRIPT LANGUAGE="VBScript">
Function Init()
	With G2Host1
		.DataSource("Items") = "C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb"
		.DataMember("Items") = "Employees"
		.DataField(0) = "Items"
		.HostReadOnly = 240 ' HostReadOnlyEnum.exHostAllowUpdate Or HostReadOnlyEnum.exHostAllowDelete
	End With
End Function
</SCRIPT>
</BODY>

C# for /COM

axG2Host1.set_DataSource("Items","C:\\Program Files\\Exontrol\\ExG2Host\\Sample\\sample.accdb");
axG2Host1.set_DataMember("Items","Employees");
axG2Host1.set_DataField(EXG2HOSTLib.HostObjectFieldEnum.exItemsDataSource,"Items");
axG2Host1.HostReadOnly = EXG2HOSTLib.HostReadOnlyEnum.exHostAllowUpdate | EXG2HOSTLib.HostReadOnlyEnum.exHostAllowDelete;

X++ (Dynamics Ax 2009)

public void init()
{
	;

	super();

	exg2host1.DataSource("Items","C:\\Program Files\\Exontrol\\ExG2Host\\Sample\\sample.accdb");
	exg2host1.DataMember("Items","Employees");
	exg2host1.DataField(0/*exItemsDataSource*/,"Items");
	exg2host1.HostReadOnly(240/*exHostAllowUpdate | exHostAllowDelete*/);
}

Delphi 8 (.NET only)

with AxG2Host1 do
begin
	set_DataSource('Items','C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb');
	set_DataMember('Items','Employees');
	set_DataField(EXG2HOSTLib.HostObjectFieldEnum.exItemsDataSource,'Items');
	HostReadOnly := Integer(EXG2HOSTLib.HostReadOnlyEnum.exHostAllowUpdate) Or Integer(EXG2HOSTLib.HostReadOnlyEnum.exHostAllowDelete);
end

Delphi (standard)

with G2Host1 do
begin
	DataSource['Items'] := 'C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb';
	DataMember['Items'] := 'Employees';
	DataField[EXG2HOSTLib_TLB.exItemsDataSource] := 'Items';
	HostReadOnly := Integer(EXG2HOSTLib_TLB.exHostAllowUpdate) Or Integer(EXG2HOSTLib_TLB.exHostAllowDelete);
end

VFP

with thisform.G2Host1
	.Object.DataSource("Items") = "C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb"
	.Object.DataMember("Items") = "Employees"
	.Object.DataField(0) = "Items"
	.HostReadOnly = 240 && HostReadOnlyEnum.exHostAllowUpdate Or HostReadOnlyEnum.exHostAllowDelete
endwith

dBASE Plus

local oG2Host

oG2Host = form.EXG2HOSTACTIVEXCONTROL1.nativeObject
oG2Host.Template = [DataSource("Items") = "C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb"] // oG2Host.DataSource("Items") = "C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb"
oG2Host.Template = [DataMember("Items") = "Employees"] // oG2Host.DataMember("Items") = "Employees"
oG2Host.Template = [DataField(0) = "Items"] // oG2Host.DataField(0) = "Items"
oG2Host.HostReadOnly = 240 /*exHostAllowUpdate | exHostAllowDelete*/

XBasic (Alpha Five)

Dim oG2Host as P

oG2Host = topparent:CONTROL_ACTIVEX1.activex
oG2Host.Template = "DataSource(`Items`) = `C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb`" // oG2Host.DataSource("Items") = "C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb"
oG2Host.Template = "DataMember(`Items`) = `Employees`" // oG2Host.DataMember("Items") = "Employees"
oG2Host.Template = "DataField(0) = `Items`" // oG2Host.DataField(0) = "Items"
oG2Host.HostReadOnly = 240 'exHostAllowUpdate + exHostAllowDelete

Visual Objects


oDCOCX_Exontrol1:[DataSource,"Items"] := "C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb"
oDCOCX_Exontrol1:[DataMember,"Items"] := "Employees"
oDCOCX_Exontrol1:[DataField,exItemsDataSource] := "Items"
oDCOCX_Exontrol1:HostReadOnly := exHostAllowUpdate | exHostAllowDelete

PowerBuilder

OleObject oG2Host

oG2Host = ole_1.Object
oG2Host.DataSource("Items","C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb")
oG2Host.DataMember("Items","Employees")
oG2Host.DataField(0,"Items")
oG2Host.HostReadOnly = 240 /*exHostAllowUpdate | exHostAllowDelete*/

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Set ComDataSource "Items" to "C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb"
	Set ComDataMember "Items" to "Employees"
	Set ComDataField OLEexItemsDataSource to "Items"
	Set ComHostReadOnly to (OLEexHostAllowUpdate + OLEexHostAllowDelete)
End_Procedure

XBase++

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

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

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

	oG2Host := XbpActiveXControl():new( oForm:drawingArea )
	oG2Host:CLSID  := "Exontrol.G2Host.1" /*{DFE195F7-4F43-482A-A14B-0C97B032A5E1}*/
	oG2Host:create(,, {10,60},{610,370} )

		oG2Host:SetProperty("DataSource","Items","C:\Program Files\Exontrol\ExG2Host\Sample\sample.accdb")
		oG2Host:SetProperty("DataMember","Items","Employees")
		oG2Host:SetProperty("DataField",0/*exItemsDataSource*/,"Items")
		oG2Host:HostReadOnly := 240/*exHostAllowUpdate+exHostAllowDelete*/

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