LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to call an .exe (non-LabVIEW, such as Notepad) in a child windown on the front panel?

Solved!
Go to solution
Highlighted

I would like to run an independent .exe inside my VI's front panel.  This is a piece of software from the vendor of a sensor I'm trying to integrate into my VI.  I was able to find how to call the .exe using .NET constructor and invoke nodes.  However, the application opens in its own window.  Is there a way to cause it to run from a child window inside the front panel (ideally, inside a tab control on the front panel)? 

 

I'm running LabVIEW 8.6.   

 

 

Thank you. 

 

0 Kudos
Message 1 of 13
(3,469 Views)
Highlighted

In a word, no. If the application can be compiled into an ActiveX control then you can put it in an ActiveX Container.

 

Also, you do not need to resort to .NET to call an executable. The System Exec function will do that as well.

0 Kudos
Message 2 of 13
(3,464 Views)
Highlighted

Thanks for the pointer.  I had actually seen that System Exec would accomplish this as well; it just looked like .NET might allow more control or options, so I had been experimenting with it.

 

 

I've not used ActiveX much.  If this is a program to whose source code I don't have access, am I correct to assume that I won't be able to compile it into an ActiveX control?

0 Kudos
Message 3 of 13
(3,457 Views)
Highlighted

There is a way to do it.  If you use the WinAPI function SetParent, you can set the program's parent to your LabVIEW window.  You can also use several other functions that can be found in MSDN (SetWindow) and lvwutil32 to move the window around and position it.

 

The problem is that you will have to open the window first to get the Window Handle to move it into LabVIEW.  I was fortunate that the 2 programs I was doing this with remembered their last position, so they would come up in the place I was goign to put them in the LabVIEW window so you didn't see the window jumping around.  But, I did use SetWindow to remove the file menu and title bar and the user could visibly see that occur, although it happened pretty fast.  For them it was worth it so that they didn't have to worry about window Z-position and I didn't have to continually reset it so that the LabVIEW window was always behind the other windows.

0 Kudos
Message 4 of 13
(3,451 Views)
Highlighted

 

Matthew,

I'm afraid I'm fairly new to LabVIEW, and completely inexperienced with WinAPI.  Is SetParent a VI, or is this something I do outside LabVIEW?  Same questions for MSDN and lvwutil32. 

 

Thanks.

0 Kudos
Message 5 of 13
(3,436 Views)
Highlighted
I don't think that would actually work. My understanding is limited regarding that function, but from I've read it only works with popups and windows that are already children. An application's main window would not be a child window.
0 Kudos
Message 6 of 13
(3,435 Views)
Highlighted

It is a Windows DLL function and you would have to use the Call Library Function.  If you are new to LabVIEW, I do not know that you would want to proceed down this path.

 

MSDN is microsoft's documentation of it's dll's and other windows API functions.  lvwutil32 is a set of VIs someone else wrote (you can find them on NI's website) to allow some of the basic window manipulation available in the Windows API.

0 Kudos
Message 7 of 13
(3,428 Views)
Highlighted
Solution
Accepted by topic author Sparticus

smercurio_fc wrote:
I don't think that would actually work. My understanding is limited regarding that function, but from I've read it only works with popups and windows that are already children. An application's main window would not be a child window.

 

I've done it before.  I attached a simple example using Notepad.  Make sure Notepad is already open with no file open.  Since the example doesn't set the position of the child window, the position relative to the window will be the same as it is relative to the desktop.  So, make sure the top left corner of Notepad is close to the origin of the Desktop.
Message Edited by Matthew Kelton on 08-14-2009 03:17 PM
Message 8 of 13
(3,422 Views)
Highlighted
Never too old to learn new tricks, I say. Smiley Very Happy
0 Kudos
Message 9 of 13
(3,403 Views)
Highlighted

smercurio_fc wrote:
I don't think that would actually work. My understanding is limited regarding that function, but from I've read it only works with popups and windows that are already children. An application's main window would not be a child window.

Actually it does work and I'm sure some people at Microsoft sweared quite a lot about having to implement that in Windows 32 bit. Back in Windows 3.1 days this was trivial since all processes shared the same memory so having two windows interacting with each others windows message queue was not a big problem. In Windows 32 bit however each process has its own private virtual memory pool and tying two message loops in such a way together is not something straightforward. They managed to make it work, mostly for reasons of backwards compatibility and for not to complicated applications. LabVIEW's Windows message handling however is delicate at least, doing all kinds of non-standard event handling and there is a real chance that embedding another applications main window could lead to very strange results if that applications Windows message loop is also doing some non standard things too.

 

So no problem doing it with simple programs like Notepad, but I would have a bad feeling about trying that with Microsoft Word for instance or some other similar high complex application.

 

Rolf Kalbermatter 

Message Edited by rolfk on 08-17-2009 10:26 AM
Rolf Kalbermatter
Averna BV
Message 10 of 13
(3,344 Views)