LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I load a picture and use it in ActiveX in run time ??

Hi:

The single function VB ActiveX dll option works OK;  but it is not that straightforward:

Here is how it was done:

STEP 1: Create a Single Function ActiveX DLL in VB
---------------------------

Create an ActiveX  *.dll COM component in VB6. You must have the professional edition of VB to do this.

Here is the simple code for the *.dll

Public Function GetPicture(ByRef FileName as String) as IPictureDisp

       Set GetPicture = LoadPicture(FileName)

End Function


. . . basically the above code is just a 'wrapper' of the 'LoadPicture' Function.

STEP 2:  Run and/or Compile the *.DLL
----------------

Make sure that you run the dll code at least once in VB so that the *.dll can register itself in the OS. Otheriwse, if you have LabVIEW on a different computer, you will have to compile the *.dll in VB. and create an installer to use on that other computer

STEP 3. Reference the *.DLL and Call in LabVIEW
---------------

The code to call this dll in LabVIEW is attached


STEP 4.  Set LabVIEW VI Preffered Execution System to 'USER INTERFACE'
-----------------------------------

The VI's property called 'Preffered Execution System' must be 'User Interface' otherwise you will get a 'Catastrophic Error' when running this dll


Let me know what you think about this method


Anthony L.




Message 11 of 17
(997 Views)
Hi  Anthony,
This method works! This is exactly what I need.
But I think that the key is "STEP 4.  Set LabVIEW VI Preffered Execution System to 'USER INTERFACE'"
By this setting, the ole picture interface can be validly used.
How did you find it?
 
Anyway, many thanks.Smiley Happy
 
0 Kudos
Message 12 of 17
(982 Views)
Hi Sealiker:

Oh, I am actually a VB programmer who moved to LabVIEW because of the fun stuff that LabVIEW offers. So I developed this after you hinted to me that ImageX has such a method. The trick to set preffered execution method to "User Interface" is actually on NI's Knowledge base --see this link: 

http://digital.ni.com/public.nsf/allkb/86256A47004E16D18625687E0076727A

I was getting this error so I searched and luckily found a solution from NI.'

So the success of this method is because of:

1. Your motivation to have me see this possibility (Thanks!)
2. Me deciding to try your lead
3. NI having a good knowledgbase that solved a tricky situation that would have otherwise prevented us from getting a working solution (Thanks NI!)

Anthony Lukindo
0 Kudos
Message 13 of 17
(976 Views)

Hi anthony !

I think this DLL can help me very much.

can you please send it to me ?

0 Kudos
Message 14 of 17
(424 Views)

Hi Hookso

 

Here is the dll

 

Anthony Lukindo

Mezintel Inc.

Message 15 of 17
(418 Views)

Hi Hookso:

 

Just remember to copy the dll to the path:

 

C:\Windows\System32  (If using Windows XP 32-bit)

 

or

 

C:\Windows\SysWOW64 (If using Wndows-7 64-bit)

 

 

Then regsiter the file using the DOS command as follows:

 

RegSvr32  " <Path>\Picture_Get.dll"  

 

Be sure to enclose the path with quotes

 

If using Windows-7 be sure to run the DOS command console as administartor

 

Regards

 

Anthony Lukindo

Mezintel Inc.

0 Kudos
Message 16 of 17
(416 Views)
Thank u very much, anthony!
0 Kudos
Message 17 of 17
(413 Views)