Search code examples
c#winformsactivexaxhosttopaz-signatures

Make an ActiveX control work without a form?


We are using Topaz Signature pads. They provide their APIs in the from of an ActiveX control which is to be put on a Winform control. Well, the way our project will work we do not want to have a form(at least not visible). We just want for the signature ActiveX control to get an image in the background.

static AxSigPlus sig = new AxSIGPLUSLib.AxSigPlus();

public static void Begin()
{
    ((System.ComponentModel.ISupportInitialize)(sig)).BeginInit();
    sig.Name = "sig";
    sig.Location = new System.Drawing.Point(0, 0);
    sig.Size = new System.Drawing.Size(0, 0);
    sig.Enabled = true;

    sig.TabletState = 1; //error here
    sig.SigCompressionMode = 0;
}

Ok so I get an error at the marked line. The exception is

Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.

What do I do to solve this problem? Would it just be easier to create a new hidden form and put the control on it so it's invisible?


Solution

  • Actually it ended up that Topaz provided an ActiveX control and a .Net wrapper around it. I switched to the .Net wrapper and it doesn't require being placed on a form or anything. I will leave the question up though because had it not been for that wrapper I would actually be dealing with it.