property NETHostCtrl.hWnd as Long
Indicates the handle to the window ( HWND ) that hosts the assembly.

TypeDescription
Long A Long expression that indicates the handle to the window ( HWND ) that hosts the assembly.
The hWnd property returns the handle of the window that displays the NETHost control. The hWnd property does not return the handle of the hosting control. The Microsoft Windows operating environment identifies each form and control in an application by assigning it a handle, or hWnd. The hWnd property is used with Windows API calls. Many Windows operating environment functions require the hWnd of the active window as an argument. The Host property returns the object being created and hosted by the NETHost control. The hosting control's properties or methods must be called using the Item, SetTemplateDef or Template property.  

The following samples shows how you can get the hwnd/handle of the hosting control. In the following sample, the Item property calls the Handle property of the System.Windows.Forms.Control type.

VBA (MS Access, Excell...)

With NETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	Debug.Print( .Host.Item("Handle").AsInt )
End With

VB6

With NETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	Debug.Print( .Host.Item("Handle").AsInt )
End With

VB.NET

With Exnethost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	Debug.Print( .Host.Item("Handle").AsInt )
End With

VB.NET for /COM

With AxNETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	Debug.Print( .Host.Item("Handle").AsInt )
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");
OutputDebugStringW( _bstr_t(spNETHost1->GetHost()->GetItem(L"Handle")->GetAsInt()) );

C++ Builder

NETHost1->AssemblyLocation = L"C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll";
OutputDebugString( PChar(NETHost1->Host->get_Item(L"Handle")->AsInt) );

C#

exnethost1.AssemblyLocation = "C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll";
System.Diagnostics.Debug.Print( exnethost1.Host["Handle"].AsInt.ToString() );

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";
	alert( NETHost1.Host.Item("Handle").AsInt );
}
</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"
		alert( .Host.Item("Handle").AsInt )
	End With
End Function
</SCRIPT>
</BODY>

C# for /COM

axNETHost1.AssemblyLocation = "C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll";
System.Diagnostics.Debug.Print( axNETHost1.Host["Handle"].AsInt.ToString() );

X++ (Dynamics Ax 2009)

public void init()
{
	;

	super();

	exnethost1.AssemblyLocation("C:\\Windows\\assembly\\GAC_MSIL\\System.Windows.Forms\\2.0.0.0__b77a5c561934e089\\System.Windows.Forms.dll");
	print( exnethost1.Host().Item("Handle").AsInt() );
}

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';
	OutputDebugString( Host.Item['Handle'].AsInt );
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';
	OutputDebugString( Host.Item['Handle'].AsInt );
end

VFP

with thisform.NETHost1
	.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
	DEBUGOUT( .Host.Item("Handle").AsInt )
endwith

dBASE Plus

local oNETHost

oNETHost = form.Activex1.nativeObject
oNETHost.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
? Str(oNETHost.Host.Item("Handle").AsInt) 

XBasic (Alpha Five)

Dim oNETHost 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.Host.Item("Handle").AsInt 

Visual Objects


oDCOCX_Exontrol1:AssemblyLocation := "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
OutputDebugString(String2Psz( AsString(oDCOCX_Exontrol1:Host:[Item,"Handle"]:AsInt) ))

PowerBuilder

OleObject oNETHost

oNETHost = ole_1.Object
oNETHost.AssemblyLocation = "C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll"
MessageBox("Information",string( String(oNETHost.Host.Item("Handle").AsInt) ))

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"
	Variant v
	Variant voNETHostObject
	Get ComHost to voNETHostObject
	Handle hoNETHostObject
	Get Create (RefClass(cComNETHostObject)) to hoNETHostObject
	Set pvComObject of hoNETHostObject to voNETHostObject
		Variant voNETHostObject1
		Get ComItem of hoNETHostObject "Handle" to voNETHostObject1
		Handle hoNETHostObject1
		Get Create (RefClass(cComNETHostObject)) to hoNETHostObject1
		Set pvComObject of hoNETHostObject1 to voNETHostObject1
			Get ComAsInt of hoNETHostObject1 to v
		Send Destroy to hoNETHostObject1
	Send Destroy to hoNETHostObject
	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 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"
		DevOut( Transform(oNETHost:Host:Item("Handle"):AsInt(),"") )

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