exnethost - sample code

How can I add a DateTimePicker?

VBA (MS Access, Excell...)

With NETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	.AssemblyName = "System.Windows.Forms.DateTimePicker"
	With .Host
		.SetTemplateDef "Dim date"
		.SetTemplateDef #1/1/2001#
		.Template = "Value = date"
	End With
End With

VB6

With NETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	.AssemblyName = "System.Windows.Forms.DateTimePicker"
	With .Host
		.SetTemplateDef "Dim date"
		.SetTemplateDef #1/1/2001#
		.Template = "Value = date"
	End With
End With

C++

/*
	Copy and paste the following directives to your header file as
	it defines the namespace 'exontrol_NETHost' for the library: 'Exontrol NETHost ActiveX Component'

	#import <exontrol.NETHost.tlb>
*/
exontrol_NETHost::INETHostCtrlPtr spNETHost1 = GetDlgItem(IDC_NETHOST1)->GetControlUnknown();
spNETHost1->PutAssemblyLocation(L"C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll");
spNETHost1->PutAssemblyName(L"System.Windows.Forms.DateTimePicker");
exontrol_NETHost::INETHostObjectPtr var_NETHostObject = spNETHost1->GetHost();
	var_NETHostObject->SetTemplateDef("Dim date");
	var_NETHostObject->SetTemplateDef(COleDateTime(2001,1,1,0,00,00).operator DATE());
	var_NETHostObject->PutTemplate(L"Value = date");

C++ Builder

NETHost1->AssemblyLocation = L"C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll";
NETHost1->AssemblyName = L"System.Windows.Forms.DateTimePicker";
Exontrol_nethost_tlb::INETHostObjectPtr var_NETHostObject = NETHost1->Host;
	var_NETHostObject->SetTemplateDef(TVariant("Dim date"));
	var_NETHostObject->SetTemplateDef(TVariant(TDateTime(2001,1,1).operator double()));
	var_NETHostObject->Template = L"Value = date";

JScript/JavaScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:FDCBA3E0-4E2F-4DC7-B073-EAA7BD7EC565" id="NETHost1"></OBJECT>

<SCRIPT LANGUAGE="JScript">
function Init()
{
	NETHost1.AssemblyLocation = "C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll";
	NETHost1.AssemblyName = "System.Windows.Forms.DateTimePicker";
	var var_NETHostObject = NETHost1.Host;
		var_NETHostObject.SetTemplateDef("Dim date");
		var_NETHostObject.SetTemplateDef("1/1/2001");
		var_NETHostObject.Template = "Value = date";
}
</SCRIPT>
</BODY>

VBScript

<BODY onload="Init()">
<OBJECT CLASSID="clsid:FDCBA3E0-4E2F-4DC7-B073-EAA7BD7EC565" id="NETHost1"></OBJECT>

<SCRIPT LANGUAGE="VBScript">
Function Init()
	With NETHost1
		.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
		.AssemblyName = "System.Windows.Forms.DateTimePicker"
		With .Host
			.SetTemplateDef "Dim date"
			.SetTemplateDef #1/1/2001#
			.Template = "Value = date"
		End With
	End With
End Function
</SCRIPT>
</BODY>

X++ (Dynamics Ax 2009)

public void init()
{
	COM com_NETHostObject;
	anytype var_NETHostObject;
	;

	super();

	exnethost1.AssemblyLocation("C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll");
	exnethost1.AssemblyName("System.Windows.Forms.DateTimePicker");
	var_NETHostObject = exnethost1.Host(); com_NETHostObject = var_NETHostObject;
		com_NETHostObject.SetTemplateDef("Dim date");
		com_NETHostObject.SetTemplateDef(COMVariant::createFromDate(str2Date("1/1/2001",213)));
		com_NETHostObject.Template("Value = date");
}

Delphi 8 (.NET only)

with AxNETHost1 do
begin
	AssemblyLocation := 'C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll';
	AssemblyName := 'System.Windows.Forms.DateTimePicker';
	with Host do
	begin
		SetTemplateDef('Dim date');
		SetTemplateDef('1/1/2001');
		Template := 'Value = date';
	end;
end

Delphi (standard)

with NETHost1 do
begin
	AssemblyLocation := 'C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll';
	AssemblyName := 'System.Windows.Forms.DateTimePicker';
	with Host do
	begin
		SetTemplateDef('Dim date');
		SetTemplateDef('1/1/2001');
		Template := 'Value = date';
	end;
end

VFP

with thisform.NETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	.AssemblyName = "System.Windows.Forms.DateTimePicker"
	with .Host
		.SetTemplateDef("Dim date")
		.SetTemplateDef({^2001-1-1})
		.Template = "Value = date"
	endwith
endwith

dBASE Plus

local oNETHost,var_NETHostObject

oNETHost = form.Activex1.nativeObject
oNETHost.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
oNETHost.AssemblyName = "System.Windows.Forms.DateTimePicker"
var_NETHostObject = oNETHost.Host
	var_NETHostObject.SetTemplateDef("Dim date")
	var_NETHostObject.SetTemplateDef("01/01/2001")
	var_NETHostObject.Template = "Value = date"

XBasic (Alpha Five)

Dim oNETHost as P
Dim var_NETHostObject as P

oNETHost = topparent:CONTROL_ACTIVEX1.activex
oNETHost.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
oNETHost.AssemblyName = "System.Windows.Forms.DateTimePicker"
var_NETHostObject = oNETHost.Host
	var_NETHostObject.SetTemplateDef("Dim date")
	var_NETHostObject.SetTemplateDef({01/01/2001})
	var_NETHostObject.Template = "Value = date"

Visual Objects

local var_NETHostObject as INETHostObject

oDCOCX_Exontrol1:AssemblyLocation := "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
oDCOCX_Exontrol1:AssemblyName := "System.Windows.Forms.DateTimePicker"
var_NETHostObject := oDCOCX_Exontrol1:Host
	var_NETHostObject:SetTemplateDef("Dim date")
	var_NETHostObject:SetTemplateDef(SToD("20010101"))
	var_NETHostObject:Template := "Value = date"

PowerBuilder

OleObject oNETHost,var_NETHostObject

oNETHost = ole_1.Object
oNETHost.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
oNETHost.AssemblyName = "System.Windows.Forms.DateTimePicker"
var_NETHostObject = oNETHost.Host
	var_NETHostObject.SetTemplateDef("Dim date")
	var_NETHostObject.SetTemplateDef(2001-01-01)
	var_NETHostObject.Template = "Value = date"

Visual DataFlex

Procedure OnCreate
	Forward Send OnCreate
	Set ComAssemblyLocation to "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	Set ComAssemblyName to "System.Windows.Forms.DateTimePicker"
	Variant voNETHostObject
	Get ComHost to voNETHostObject
	Handle hoNETHostObject
	Get Create (RefClass(cComNETHostObject)) to hoNETHostObject
	Set pvComObject of hoNETHostObject to voNETHostObject
		Send ComSetTemplateDef of hoNETHostObject "Dim date"
		Send ComSetTemplateDef of hoNETHostObject "1/1/2001"
		Set ComTemplate of hoNETHostObject to "Value = date"
	Send Destroy to hoNETHostObject
End_Procedure

XBase++

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

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

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

	oNETHost := XbpActiveXControl():new( oForm:drawingArea )
	oNETHost:CLSID  := "Exontrol.NETHost" /*{FDCBA3E0-4E2F-4DC7-B073-EAA7BD7EC565}*/
	oNETHost:create(,, {10,60},{610,370} )

		oNETHost:AssemblyLocation := "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
		oNETHost:AssemblyName := "System.Windows.Forms.DateTimePicker"
		oNETHostObject := oNETHost:Host()
			oNETHostObject:SetTemplateDef("Dim date")
			oNETHostObject:SetTemplateDef("01/01/2001")
			oNETHostObject:Template := "Value = date"

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