I'm having trouble creating an ActiveX add-on for Hummingbird DM, but I don't think it's the DM that's the problem, but how I make the ActiveX control. The API states that you must create an ActiveX Control and implement the SetSelection method. The example in the API is in VB6, and I've sucessfully done that by:
1. Creating a new VB ActiveX project
2. Added the code:
Public Sub SetSelection(ByVal oa As BCObjectArray)
Label1.Caption = "You have selected " & oa.Size & " items..."
End Sub
3. Registered it with DM
The VB code works as advertised, but when I try to do the same with C# I can't get it to work properly. I've created a new Windows Control Library, and made the assembly COM visible and Register for COM interop, and the code looks like:
namespace AddOn
{
[ClassInterface(ClassInter
faceType.A
utoDispatc
h)]
public partial class Main : UserControl
{
public Main()
{
InitializeComponent();
AddToLog ("ActiveX created");
}
private void AddToLog(string message)
{
using (StreamWriter writer = File.AppendText(@"C:\log.t
xt"))
{
writer.WriteLine (DateTime.Now.ToLongTimeSt
ring() + " " + message);
writer.Close();
}
}
public void SetSelection(DECoreLib.BCO
bjectArray
oa)
{
AddToLog ("inside setselection");
label1.Text = oa.Size().ToString() + " documents selected";
}
}
}
What happens in the DM is that the DM finds the dll and creates the dll (the AddToLog method gets called in Main), but the SetSelection method never gets called (and the GUI displays nothing where the ActiveX is supposed to be displayed). Looking with OleViewer at the Addon.tlb it looks to me that the dll is registered correctly:
...
// Forward declare all types defined in this typelib
interface _Main;
[
uuid(860DF00D-D514-49A7-90
57-66B781D
06CDA),
version(1.0),
custom({0F21F359-AB84-41E8
-9A78-36D1
10E6D2F9},
"vbctrl.Main")
]
coclass Main {
interface _Object;
interface IComponent;
interface IDisposable;
interface IWin32Window;
[default] interface _Main;
};
[
odl,
uuid(55C58EDC-D34C-4DF8-B4
57-DD30AAA
E1613),
version(1.0),
dual,
oleautomation,
custom({0F21F359-AB84-41E8
-9A78-36D1
10E6D2F9},
"vbctrl.Main+_Main")
]
interface _Main : IDispatch {
[id(0x00000001)]
HRESULT SetSelection([in] IBCObjectArray* oa);
};
I guess it still has something with how I register the control? I've tried with [ClassInterface(ClassInter
faceType.A
utoDual)] and [ClassInterface(ClassInter
faceType.N
one)] (and implementing an interface with the SetSelection method), and without [ClassInterface...]. None of them more sucessful than the other...
Start Free Trial