How do I use the Ranger ActiveX control in my .NET environment?

Started by ForumAdmin, March 31, 2008, 11:36:57 AM

Previous topic - Next topic

ForumAdmin

How do I use the Ranger ActiveX control in my .NET environment?

Bryan Clark

There are two approaches to incorporate an ActiveX control into a Dot Net environment.

The first approach involves adding the control into a form:

Under [tools], please select "Add/Remove Toolbox Items..." or "Choose Toolbox Items..." to view the list of COM components in order to add the active X control to the tool box.  On the form view, drag the active X control from the toolbox that was added previously.  By doing so, both the Ax[OCX name]Lib and [OCX name]Lib references will be created.   Furthermore, the location of the resources, Interop.[OCX name]Lib.DLL and Ax[OCX name]Lib.DLL, should be under either the release or debug folders, depending on the configuration you are running.  These files will be generated into the appropriate folder once you switch the build configuration if the file is not found as long as the OCX is registered.  Once the interop references have been added, all methods and events will become available to the application.  If the OCX is not available, please register the control as follows:

1) Select [Start Menu]
2) Select [Run]
3) type [regsvr32 "[drive]:\[full path]\[OCX name].ocx"] and press [enter]
4) You will see a message indicating that the registration succeeded.

The second approach is to create the interop files, mentioned above, manually and add them to the project without the use of forms:

Both the Ax[OCX name]Lib and [OCX name]Lib references must be created manually by using Aximp.exe; Aximp.exe is found under the Visual Studio folder:

"aximp /out:[Full path to store interop files]\Ax[OCX name]Lib.dll  [full path to OCX]\[file name].ocx"

Add the [activeXControl name]Lib.dll and Ax[activeXControl name]Lib.dll files to the project as follows:
•    Select 'Project'.
•    Select 'Add Reference'.
•    Under the '.Net' tab, select 'System.Windows.Forms.dll' if not added by default.
•    Browse to the folder containing the interop DLL files created previously and add them to the project as well.

Create an object of type [activeXControl name] in the application as follows:

VB. Net:
Dim OCXVar As New Ax[activeXControl]Lib.Ax[OCX name]
OCXVar.CreateControl()

C#:
Ax[activeXControl]Lib.[OCX name] OCXVar = new Ax[activeXControl]Lib.Ax[OCX name]();

OCXVar.CreateControl();

Please note that the call to CreateControl is imperative in order to initialize the control before usage.



Ranger® - The universal check scanner interface
Copyright © 2009 Silver Bullet Technology
www.sbullet.com