LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up and using an ActiveX control

Trying to use an ActiveX control I added to my CVI project.  I use the ActiveX Controller Wizard to create an ActiveX control.  Then I tried using one of the ActiveX control functions but it requires I get an Object Handle.  The ActiveX Control Help says I can get the Object Handle by using GetObjHandleFromActiveXCtrl or an ActiveX method or property.  I looked through all the functions my ActiveX control has and could not find anything that would get an Object Handle.  The GetObjHandleFromActiveXCtrl function requires a panel handle which my project does not have or use.  Any suggestions on what to do next?

 

The ActiveX control I am using is Mint Controls Build 5708 from ABB. 

0 Kudos
Message 1 of 5
(5,958 Views)
Hi,
Just to make sure you're talking about ActiveX controls and not servers or documents, controls have to be instantiated by placing them in a 'form' or in CVI's case, a panel.
More information can be found here :
http://zone.ni.com/reference/en-XX/help/370051T-01/cvi/uiref/cviprogramming_with_activex_control/
There's also an old example here :
http://www.ni.com/example/29143/en/
Thanks
Sacha
// it takes almost no time to rate an answer Smiley Wink
0 Kudos
Message 2 of 5
(5,927 Views)

Hi

New in ActiveX controls...I cannot help to recreate examples like Media Player (which works perfectly on my PC).

Well I take the first method of"Programming with ActiveX Controls" topic:

  1. From the Tools menu of any LabWindows/CVI window, select Create ActiveX Controller. When you run the wizard in this manner, you need to select the ActiveX server that corresponds to your control.

First I find two "Windows Media Player", which one ? Some trials lead me to the second one, where I retrieve functions names of the example (?).

Next window : I let Instrument Prefix as "MediaPlayer", I browse a target fp file as "wmp" in my project directory, let the default compatibility options.

Next window : I don't change any "Advanced Options", success...

I find a new intrument "Windows Media Player", and 5 files wmp.fp/c/h/sub/obj. OK.

But I want to see the control on a panel : I open my uir, go to "Create/ActiveX", select "create control".

But what about "Validate servers" check box ? Il let it unchecked.

I find "Windows Media Player" (only one) in the list, and the control appears on the panel, but the aspect is different from the example (some property changed?):

 

wmp1.gif

If I edit the control, I find a property list that seems different from the example (even if I expand all) :

wmp2.gif

Well it seems that controls are different ?

I insert some lines in my code ("hello.mp3" is in the project directory):

	GetObjHandleFromActiveXCtrl (PanelHandle, PANEL_WINDOWSMEDIAPLAYER,&mediaHandle);
	MediaPlayer_IMediaPlayer2SetFileName (mediaHandle, NULL, "Hello.mp3");
	MediaPlayer_IMediaPlayer2Play (mediaHandle, NULL);

Build OK. But nothing played. Error code from "SetFileName" function = -2147467262, error text : "Cette interface n'est pas prise en charge" something like "this interface is not supported" :

wmp3.gif

 

Any idea ?

Thanks in advance !

JP

 

(Windows XP/CVI2010)

0 Kudos
Message 3 of 5
(5,187 Views)

Hi jpscholet,

 

Have you taken a look at the help document below?

 

Programming with ActiveX Controls:

http://zone.ni.com/reference/en-XX/help/370051T-01/cvi/uiref/cviprogramming_with_activex_control/

 

Where is the MediaPlayer example that you're trying to recreate from? Is this in a tutorial somewhere?

Kelsey W.
National Instruments
Applications Engineer
0 Kudos
Message 4 of 5
(5,153 Views)

basket_weaver a écrit :

Hi jpscholet,

 

Have you taken a look at the help document below?

 

Programming with ActiveX Controls:

http://zone.ni.com/reference/en-XX/help/370051T-01/cvi/uiref/cviprogramming_with_activex_control/

 

Where is the MediaPlayer example that you're trying to recreate from? Is this in a tutorial somewhere?


Hi basket_weaver

Yes I have tried to use the indicated help page...

I used an old example like this one : http://www.ni.com/example/26428/en/.

But inside this other page : http://www.ni.com/example/29600/en/ NI explains some changes in Windows Media Player, and why I have problems to recreate an old example (my WMP version is 9), and that I have to use setURL function instead of the previous setFileName function.

So using Create ActiveX Controller needs to choose in the list the first item corresponding to the newest version.

But I solved the problem without using this command, I just inserted the WMP control in my uir (with "Validate Servers" unchecked) and called "Generate ActiveX Control Driver".

Code had been changed for instance to :

GetObjHandleFromActiveXCtrl (WMPPanelHandle, WMPPANEL_WINDOWSMEDIAPLAYER,&mediaHandle);
WMPLib_IWMPCoreSetURL (mediaHandle, NULL, audiofilename);

 And it works. I just wonder why the control cannot access to all the WMP usual commands, like loading a new file. And why it's impossible to disable these useless visualizations...

Thanks for help !

JPS

0 Kudos
Message 5 of 5
(5,131 Views)