From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Launch CVI-created program minimized from within other CVI program

Hey all,

 

     I'm trying to run a program I created in CVI v9.0 by calling the compiled executable from within other CVI source code using "LaunchExecutableEx".  I want it to run minimized and eventually completely hidden.  It has a user interface that I would like to hide from the user when it is called remotely like this.  When I use LaunchExecutableEx" and tell it to run LE_SHOWMINIMIZED or LE_HIDE it still shows up as open and positioned normally (i.e. not minimized, not maximized, not hidden).  Am I missing some compiler setting on my CVI program whose executable I am calling or is this a feature that isn't present in CVI?  FYI, my OS is Windows XP. Thanks.

0 Kudos
Message 1 of 4
(4,238 Views)

Hi AndyP123,

 

You might want to take a look at this knowledgebase articl, which describes launching an executable with options:

 

Knowledgebase 4RJ56TLT: How Can I Launch and Control Another Application in LabWindows/CVI?

 

This article shows how you can implement command line arguments into your exe, allowing you to run different code depending on the presence of a code at the end of the launch call.  in the example provided, the argument will launch the EXE in a full window if the argument is present.  You could then use the HidePanel function in your called EXE to hide it when a certain argument is present.

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 2 of 4
(4,208 Views)

Al B,

 

     Thanks for the information about command line parameters.  I guess my question had a hidden meaning behind it.  I don't want to control how the program handles by putting in command line parameters and doing the work myself.  I want to open ANY executable by calling it within a CVI program and tell it to keep itself minimized or hide itself completely.  Then I will kill it within my CVI program so the user interface on the executable (if there is one) is never seen by the user.  I was hoping that the "windowState" parameter in the function "LaunchExecutableEx" would actually perform this minimizing or hiding for me.  I assumed that Windows would do the minimizing or hiding of the program after CVI tells it to run the executable that way.  The example in the Knowledgebase uses LE_MINIMIZED in the call to "LaunchExecutableEx" and yet it says the executable's window will open normally or maximized because of how it was written and the command line parameter it was passed.  Maybe I misinterpretted the intent behind the "windowState" parameter?  What is the use of this parameter then?  Thanks.

0 Kudos
Message 3 of 4
(4,150 Views)

AndyP:

 

I think the problem is that LabWindows opens multiple hidden windows before it opens the UI window.  Apparently the window that gets the minimize message is one of the hidden windows, and not the main UI window.

 

I have attached a sample app that lets you open various apps (from a CVI app), and control how the app's window is shown (the window state).  You can control the window state at startup (which works for notepad.exe, but not for CVI-built apps) or sometime later by clicking another button.  It lets you control the delay between the time you start the app until you try to control it.  It comes with three apps to choose from, CVI_test_app (included), notepad.exe, and calc.exe.  You can also try your own program by right-clicking on the app select listbox and browsing to another exe.

 

You need to build the CVI_test_app, and then the WindowsControl app.  More info is in the ReadMe file in the attached zip file.

 

The included CVI_test_app that is just a panel with a Quit button.  This simple app actually opens 10 windows! (According to the Windows SDK EnumWindows command).

If the delay after opening the CVI app is too short, you don't get a window handle to the main UI window, so later commands to minimize or maximize don't work as intended.

 

The app uses the Windows SDK CreateProcess command to launch the app, since that gives more useful information that can be used to later control that app's windows.

 

In order to build this project, you need to have the Windows SDK installed, which is included in the CVI Full Development System and the NI Developer Suite (but not in the CVI Base package).   It's an option, not installed by default.  So if you don't have it, you need to reinstall CVI and select a custom install to select the SDK (or Windows API in later versions).

Message 4 of 4
(4,121 Views)