-
Re: How to add the edrawings activeX control 2016/2017 to VB.NET ?
Jeetendra Prasad Jun 16, 2017 7:08 AM (in response to Vincent Li)Hi,
VS, being 32bit, makes this a big pain for 64bit activex controls. For achieving that You need to add edrawing dynamically into your winform dialog. Here is the snippet of code:-
edrawing control host wrapper class:
partial class eDwHost : System.Windows.Forms.AxHost
{
public eDwHost()
: base("{22945A69-1191-4DCF-9E6F-409BDE94D101}")
{
InitializeComponent();
}
private dynamic ocx;
protected override void AttachInterfaces()
{
base.AttachInterfaces();
try
{
if (IntPtr.Size == 8) //64 bit
{
// "Forced compiler error! This code can never work in 32-bit processes since it depends on an ActiveX contronl which is only available in 64-bit."
this.ocx = (dynamic)base.GetOcx();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message + "\r\n\r\n" + ex.StackTrace, "Exception loading eModelViewControl");
}
}
public new dynamic GetOcx()
{
return (dynamic)base.GetOcx();
}
}
And in your winform code :-
eDwHost hostContainer = new eDwHost();
giveproperties to hostContainer
//((Control)hostContainer).Location // NOTE : base class is Control
//hostContainer.Size// NOTE : base class is Control
//hostContainer.AutoSize// NOTE : base class is Control
//hostContainer..Enabled// NOTE : base class is Control
To Add in winform:-
objForm.AddControl(hostContainer);
To get edrawing for apis:-
dynamic emvControl = hostContainer.GetOcx();
emvControl.OpenDoc(sViewFilePath, false, false, true, "");
Please note that I have got this from SW forum only. If you get the original post then add links to them also.
BTW : If you want try out Edrawing code for test and trial purpose then you can use it in your VBA7 editor (e.g. 64Bit excel VBA or Solidworks VBA). This makes trial code work faster as you can add then using VBA7 IDE and once you are confident then add same code in your main project in visual studio. Thats how I do it myself.
FYI: VS development team doesnt want to make VS in 64 bit in near future.
Regards,
Jeetendra Prasad
-
Re: How to add the edrawings activeX control 2016/2017 to VB.NET ?
Vincent Li Jun 19, 2017 12:39 PM (in response to Jeetendra Prasad)thanks a lot.
I am starting learning the C# program now ...
-