Programmatically Move a Window to the Front Using LabVIEW

Updated May 3, 2018

Reported In

Software

  • LabVIEW Base
  • LabVIEW Full
  • LabVIEW Professional

Issue Details

How can I programmatically move a window associated with LabVIEW or another program to the front?

Solution

This task can be easily accomplished by using two Windows APIs through the Call Library Function Node.  In this case, the Call Library Function Node will be used to call the functions, FindWindow and SetForegroundWindow, from the user32.dll.
  1. Place the Call Library Function Node (located in the Connectivity toolset) on the block diagram.  
  2. Right-click the node and select Configure.  
  3. A dialog box will appear, which will allow the user to specify the library name or path, function name, calling conventions, parameters, and return value for the node.  
  4. After clicking the OK button, the node automatically resizes to have the correct number of terminals and sets the terminals to the correct data types.  
  5. The following reveals the settings necessary for each of the two Windows APIs, FindWindow and SetForegroundWindow.

FindWindow

The following parameters should be used for this API:
ParameterTypeData Type
hWndNumericUnsigned 32-bit Integer
IpszClassNameNumericSigned 32-bit Integer
IpszWindowNameStringC String Pointer

SetForeground Window

The following parameters should be used for this API:
ParameterTypeData Type
return typeNumericSigned 32-bit Integer
HandleNumericSigned 32-bit Integer

 

Additional Information

FindWindow
This API acquires the handle of the window that you want to bring to the front. You simply pass the name of window into the lpWindowName terminal and pass a NULL into the lpClassName input. Once you have obtained the handle to the target window you can use the SetForegroundWindow API.


Version 8.0 and earlier
 

Version 8.2 and later
SetForegroundWindow 
This API moves window corresponding to the passed handle to the front.

Version 8.0 and earlier


Version 8.2 and later
 

WAS THIS ARTICLE HELPFUL?

Not Helpful