0
votes

I'd like to control when a Delphi console window becomes visible at startup. At the moment I use the following code as the first thing I do to hide the console, do other stuff, then make it visible again

showWindow(GetConsoleWindow, SW_HIDE);

... do other stuff

showWindow(GetConsoleWindow, SW_NORMAL);

However, one can still see a flash of the initial console window before it is hidden by SW_HIDE. Is there another way to hide the console window before windows even attempts to make it visible at startup?

To provide further background information, the user experience I am after is that a console screen appears centered on the screen. I know how to center the console window but I still see a flash at startup before the window is centered. I'd like to have control over when the console becomes visible so that to a user the console window appears without any ghost of a window at startup.

1
Does this answer your question? How do I hide the console window?BrowJr
I saw that but I think it doesn't answers the question. The answer given suggests removing {$APPTYPE CONSOLE} but that I think will remove the console completely. I just need to control when the console is visible at startup, I still need to show the console a few seconds later. The code above works but I can still see a flash of a console at startup.rhody

1 Answers

7
votes

A console app has no control over the initial state of the console window. The window may already exist before the app is even run, or the OS may have to create a new window for the app.

For what you are looking for, you are better off removing {$APPTYPE CONSOLE} altogether so your app is not a console app anymore, and then use AllocConsole() to create a new console window when you are ready for it.