Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Implementing GPIB I/F without CWGPIB activeX control

I am writing a class that uses GPIB. Is there a way to use the functionality of the CWGPIB activex control without having a form to put it on?
0 Kudos
Message 1 of 5
(4,224 Views)

Hi!
When you place CW++ controls on MFC application dialogs in Visual C++, the appropriate licensing information is included automatically. If you don't want to drop the control on the form, then you'll have to manually get the information. 

Mika Fukuchi
Application Engineer
National Instruments

0 Kudos
Message 2 of 5
(4,224 Views)

Hello

You would have to instantiate the controls somehow, and I think in VB, you actaully do that by either dropping the control on the form or adding it dynamically. Other than this, Im not sure how you would initialize a control. You could just hide the form if you dont wnat the user to see it. Also, you could use gpib dll to make calls to the driver directly instead of using the activex control.

I hope this helps

Bilal Durrani

Bilal Durrani
NI
0 Kudos
Message 3 of 5
(4,223 Views)

The easiest way to do this would be to drop the control on a form, expose the instance of the control as a property of the form, create the form in your class but keep it invisible, then use the property on the form to make calls on the control. This seems inelegant, but the main reason that you have to do this is that using CreateObject to dynamically instantiate the control will not initialize the control the same way that it will get initialized in a form, and the control will not be completely initialized if you create it via CreateObject.

If you would like to dynamically create the control via CreateObject and initialize the control properly so you don't have to use a form, download tl_ole.zip, unzip it, add a reference to olelib.tlb in your project, then add a reference (via Project->References, NOT Project->Components - you will probably have to browse for it) to cwinstr.ocx, and then you can dynamically create the control like this:

Dim gpib As CWGPIB
Set gpib = CreateObject("CWInstrumentControlLib.CWGPIB.1")

Dim iPersist As IPersistStreamInit
Set iPersist = gpib
iPersist.InitNew

' You can now make calls on the CWGPIB instance

Also, if you're using VB.NET, you may want to take a look at the .NET interface to GPIB. For more information, see the Measurement Studio Technology Preview Program. Hope this helps.

- Elton

0 Kudos
Message 4 of 5
(4,223 Views)
Elton,

Thanks. This is just what I was looking for.

Dan
0 Kudos
Message 5 of 5
(4,223 Views)