Page 1 of 1

Make Console diseapear

Posted: Tue Mar 17, 2009 10:15 am
by herby490
I making a program that I need the Console window to disappear but I would still like it to be able receive input so if i pressed a key the program would quit but if i did not the program would continue to loop. I have tried FreeConsole() and selecting a Gui application in Code::Blocks build options but the program keeps on repeating and I have to restart my computer to stop it. I am also using getch() to detect if a key has been pressed because I don't want to have to press enter every time I enter a key.

Re: Make Console diseapear

Posted: Tue Mar 17, 2009 10:25 am
by avansc
ummm. i dont know about code blocks. but VS just has a compiler option to not display the console. however, you will have to have some API doing keyboard IO for you, becuase cin or gets or whatever c/c++ io will not work if the console is not there.

Re: Make Console diseapear

Posted: Tue Mar 17, 2009 10:43 am
by herby490
Thanks for the info I guess Ill have to wait until I am ready to learn SDL for this program.

Re: Make Console diseapear

Posted: Tue Mar 17, 2009 10:47 am
by avansc
herby490 wrote:Thanks for the info I guess Ill have to wait until I am ready to learn SDL for this program.
if you tell me what you are planning i can advice you on how to procede

Re: Make Console diseapear

Posted: Tue Mar 17, 2009 11:17 am
by herby490
I want it so every time the user press a button a sound will play but if they press a certain button the program will quit.

Re: Make Console diseapear

Posted: Tue Mar 17, 2009 12:44 pm
by avansc
herby490 wrote:I want it so every time the user press a button a sound will play but if they press a certain button the program will quit.
so you dont want any reference window. console or GUI?

well i would use FMOD (just because i like it and its so easy to use) and i would make a simple winapi program.
you can find all the worlds info on winapi on google.

another more accessible option in my opinion would be to use something like C builder. i think VS has something like that, but i never use it.
that by default does not have a console due to its GUI'ness, and you can set that the window to visible = false or something to that tune.

Re: Make Console diseapear

Posted: Tue Mar 17, 2009 6:17 pm
by Joeyotrevor
If you just want to hide the console and still have the application running in the background, you can just do this

Code: Select all

HWND hwnd = GetConsoleWindow();
ShowWindow(hwnd, SW_HIDE);
You can still receive input if you use GetAsyncKeyState() or GetKeyState().