LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bring Window Forward Executable

Solved!
Go to solution

Hey Guys and Gals,

 

I'm trying to incorporate some code to bring my executable forward to the front of all other open programs when called to. The example here (https://forums.ni.com/t5/Example-Programs/Programmatically-Move-Any-Window-to-the-Front/ta-p/3532516) works in development, but if I make the linked vi an executable it will crash when opened. The same happens when I incorporate the code into my application, it will crash upon opening.

 

Any ideas on how to remedy this?

 

Sean

0 Kudos
Message 1 of 9
(4,687 Views)

Is the window name the same as an executable as it is in development environment?

0 Kudos
Message 2 of 9
(4,680 Views)

For my application it is.

0 Kudos
Message 3 of 9
(4,673 Views)

Is it a bitness (64bit vs 32bit) problem between your runtime and Windows DLL? 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 9
(4,651 Views)

@aputman wrote:

Is it a bitness (64bit vs 32bit) problem between your runtime and Windows DLL? 


Wouldn't bitness be the same for development and RT?

 

But then again, the bitness is probably the problem. That handle probably needs to be a system sized pointer. If you are on a 64 bit system, it will never work properly.  The development environment might live in lower regions of memory, so might succeed coincidentally.

0 Kudos
Message 5 of 9
(4,625 Views)
Solution
Accepted by topic author mckesea7010

Bring Window Forward LV2013.png

 

Tested this in 32 bit LV 2013 and 64 bit 2018.

 

No guarantees.

Message 6 of 9
(4,622 Views)

Operating system is Windows 7 64 bit, and I have 32 bit LabView 2017.

 

wiebe@CARYA, thank you for the time you took for the solution provided. It works in my executable now! I am going to study the changes you made and try to understand further the "why" behind my solved problem. I am not versed in these types of issues. Thanks again!

0 Kudos
Message 7 of 9
(4,606 Views)

@mckesea7010 wrote:

Hey Guys and Gals,

 

I'm trying to incorporate some code to bring my executable forward to the front of all other open programs when called to. The example here (https://forums.ni.com/t5/Example-Programs/Programmatically-Move-Any-Window-to-the-Front/ta-p/3532516) works in development, but if I make the linked vi an executable it will crash when opened. The same happens when I incorporate the code into my application, it will crash upon opening.


Most likely the path to the Windows DLL was altered in your Call Library Node and it now contains the entire path to the DLL rather than just the DLL name itself (user32.dll or kernel32.dll or similar).

When you build an application, LabVIEW considers DLL names with full path in the Call Library Node to be private DLLs and copies them into the application folder. On startup LabVIEW tries to specifically load that private DLL instead of the System DLL and then things start to get very haywire. These system DLLs are not programmed in a way that allows them to be instantiated from other places than the Windows System folder and on initialization they crash the whole process rather sooner than later.

 

Solution is to go into the Call Library Nodes and make sure they only specify the actual DLL name without any path. Then rebuild your executable and all is well!

Rolf Kalbermatter
My Blog
Message 8 of 9
(4,590 Views)

Hello,

 

I am not sure if it can help but i was trying to make your VI working. On Windows 10 i had an issue : the window is set active (I saw a color changment on the windows' task bar) but not appear in front of the screen.

After some research I just call SetActiveWindow before call SetForegroundWindow and now it's working.

As I am a beginner to Labview, I can't really explain why it work.

Screen_Active_Window.JPG

0 Kudos
Message 9 of 9
(1,945 Views)