2012-03-08

Hiding a console window when coding in Bloodshed Dev-C++

There exist a several ways of hiding a console window of your program.
Let me explain a few of them.

First method:
#include <windows.h>

int main() {
    HWND hWnd = GetConsoleWindow();
    ShowWindow(hWnd,SW_HIDE);
}

This method will hide the console window right after it shows up. Because console window will still be displayed for a fraction of second, this is probably not a method you would want to use.

Second method:
#include <windows.h>

int main() {
    FreeConsole();
}

This method behaves same as the first one, hiding console window right after it shows up.
So let's see the last method which solves this problem.

Third method:
Considering you are using Dev-C++ by Bloodshed, do the following:
Tools > Compiler Options > Settings > Linker > Do not create a console window > Yes

This method actually doesn't hide a console window.
Because it isn't created in the first place, there is nothing to hide. :)

1 comment: