Example Programs

Showing results for 
Search instead for 
Did you mean: 

Programmatically Move Any Window to the Front


This VI will programmatically move a window to the front whether its a LabVIEW window or not.




This VI will programmatically move a window to the front whether its a LabVIEW window or not.  There are two Windows APIs that are used to achieve this.  The first one (FindWindow) acquires the handle of the window that you want to bring to the front.The name of the window is passed into the lpWindowName terminal and NULL is passed into the lpClassName terminal.  The second windows API is SetForegroundWindow. This moves the window corresponding to the passed handle to the front.




LabVIEW 2012 (or compatible)



Steps to Implement or Execute Code

1. Open the VI "Bring Window Forward_LV2012_NI Verified"

2. Choose the window name you want to bring to front
3. Run the VI
4. Stop Execution



Additional Information or References




 **This document has been updated to meet the current required format for the NI Code Exchange.**


Sara Lewandroski
Applications Engineer | National Instruments
Member michelesc


this approach seems not to work if my VI execute a SysExec and wants to keep the external application to the background.

Root cause seems you cannot move a window from a background application (that is, after LV executes Sysexec).



Member Tesla1977

This does not work in Win10. When calling the function when another application is at the front the LabVIEW window simply starts flashing in the taskbar. Any tips?

Member mckesea7010

This approach doesn't currently work for me when incorporating into an executable. Are there are any other files I need to include in my project for this to work in an executable??

Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast

Posted a new version here. (images and\or attachments are not allowed here?).


That handle needs to be a pointer sized integer.