Make Console diseapear

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
herby490
Chaos Rift Regular
Chaos Rift Regular
Posts: 122
Joined: Thu Feb 12, 2009 5:59 pm

Make Console diseapear

Post 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.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Make Console diseapear

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
herby490
Chaos Rift Regular
Chaos Rift Regular
Posts: 122
Joined: Thu Feb 12, 2009 5:59 pm

Re: Make Console diseapear

Post by herby490 »

Thanks for the info I guess Ill have to wait until I am ready to learn SDL for this program.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Make Console diseapear

Post 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
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
herby490
Chaos Rift Regular
Chaos Rift Regular
Posts: 122
Joined: Thu Feb 12, 2009 5:59 pm

Re: Make Console diseapear

Post 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.
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: Make Console diseapear

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Joeyotrevor
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 62
Joined: Thu Jan 22, 2009 6:24 pm
Programming Language of Choice: C++

Re: Make Console diseapear

Post 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().

Code: Select all

eb 0c 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 31 d2 8e c2 30 ff b3 0a bd 02 7c b9 0b 00 b8 00 13 cd 10 eb fe
Post Reply