11-21-2024 09:27 AM
I used LabWindows to create some communication DLLs, and then some .exe command line tools that use it. I am not a Windows programmer, so I do not understand what causes my program to constantly steal focus while running. For example, I run my command:
PPLogGetter.exe -parameters -etc
...then while it is spinning and running (silent, no output), I cannot select anything else in Windows. The moment I click on another window, it pops back to the DOS CMD.EXE window.
What could I change to stop this from happening? Command line programs I write using GCC directly (Code::Blocks IDE) do not act this way. I expect a simple checkbox somewhere or something?
Solved! Go to Solution.
11-26-2024 02:51 AM
Hello,
that's a usual problem. There's 2 functions for that: SetStdioWindowVisibility() or SetStdioWindowOptions(... , BringToFrontWhenModified , ...)
11-26-2024 09:08 AM
@gdargaud wrote:
Hello,
that's a usual problem. There's 2 functions for that: SetStdioWindowVisibility() or SetStdioWindowOptions(... , BringToFrontWhenModified , ...)
Thank you! I implemented this in my command line tools today at the start of main() and it did the trick:
int main (int argc, char *argv[])
{
// int SetStdioPort (int standardInputOutputPort); // HOST_SYSTEM_STDIO
// void SetStdioWindowVisibility (int visible);
// SetStdioWindowOptions (int maximumNumberOfLines, int bringToFrontWhenModified, int showLineNumbers);
SetStdioWindowOptions (10000, 0, 0); // Not Used, No, Not Used
printf ("\n"
"%s v"_TARGET_PRODUCT_VERSION_" - "__DATE__" "__TIME__"\n\n", argv[0]);
I left the various calls in comments so whoever touches this code in the future will know where to look.
01-28-2025 06:17 PM
Since these command line tools are not making use of anything LabWindows-specific, I am planning to migrate them and my DLL to a generic GCC or something. I found that not only was it stealing focus (fixed), but if I had the CMD window resized, it would pop back to default size when the app runs! No idea how to fix that one, but it’s just going to be easier to get away from this compiler I think.
02-07-2025 04:57 PM
I spent a few hours last night and got our two DLLs building using Code::Blocks (free IDE) and the GCC compiler that comes with it.
I had to make dummy files for <ansi_c.h> and one other, and since I needed to change the #define used to mark an exported DLL function, I just put that inside my ansi_c.h. Worked great! Only other change I had to make was some of the "#pragme GCC ...." ignore things I had when including windows.h and some FTDI headers (tons of compiler warnings in these) so I used "#ifdef _CVI_" around those.
GCC also found a few more compiler warnings that LabWindows was not, even with the warning level cranked up, so I fixed those two.
I tested using the DLL with a LabWindows program and it worked, so that looks good. I'll recompile all my command line stuff and then they can run without needing all the National Instruments stuff installed first, which is a nice bonus.