05-07-2019 12:09 PM
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
Solved! Go to Solution.
05-07-2019 12:13 PM
Is the window name the same as an executable as it is in development environment?
05-07-2019 12:22 PM
For my application it is.
05-07-2019 01:28 PM
Is it a bitness (64bit vs 32bit) problem between your runtime and Windows DLL?
05-08-2019 03:44 AM - edited 05-08-2019 03:47 AM
@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.
05-08-2019 03:55 AM
05-08-2019 07:58 AM
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!
05-08-2019 10:12 AM
@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!
08-04-2022 08:17 AM
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.