Advertisement

09.17.2007 at 12:29AM PDT, ID: 22832551
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Creating an activeX control in C# (and using it as a DM Add-on in Hummingbird)

Asked by Contestoas in C# Programming Language, Assembly Programming Language, ActiveX

Tags: , , ,

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(ClassInterfaceType.AutoDispatch)]
    public partial class Main : UserControl
    {
        public Main()
        {
            InitializeComponent();
            AddToLog ("ActiveX created");
        }

        private void AddToLog(string message)
        {
            using (StreamWriter writer = File.AppendText(@"C:\log.txt"))
            {
                writer.WriteLine (DateTime.Now.ToLongTimeString() + " " + message);
                writer.Close();
            }
        }

        public void SetSelection(DECoreLib.BCObjectArray 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-9057-66B781D06CDA),
      version(1.0),
        custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "vbctrl.Main")
    ]
    coclass Main {
        interface _Object;
        interface IComponent;
        interface IDisposable;
        interface IWin32Window;
        [default] interface _Main;
    };

    [
      odl,
      uuid(55C58EDC-D34C-4DF8-B457-DD30AAAE1613),
      version(1.0),
      dual,
      oleautomation,
        custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9}, "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(ClassInterfaceType.AutoDual)] and [ClassInterface(ClassInterfaceType.None)] (and implementing an interface with the SetSelection method), and without [ClassInterface...]. None of them more sucessful than the other... Start Free Trial
 
Keywords: Creating an activeX control in C# (an…
 
Loading Advertisement...
 
[+][-]09.17.2007 at 08:34PM PDT, ID: 19910072

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: C# Programming Language, Assembly Programming Language, ActiveX
Tags: activex, control, dm, hummingbird
Sign Up Now!
Solution Provided By: Kelmen
Participating Experts: 1
Solution Grade: A
 
 
[+][-]09.17.2007 at 10:09PM PDT, ID: 19910401

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_1_20070628