Disableing Console from appearing when using vc++ 6

How would I go about removing the console window from vc++ 6.0 when running a program using OpenGL. I am using glut so I dont want to go through the windows application wizard becase that requires me to have a WinMain function and then my glutInit is all messed up. What is the easiest way.

take a look at the glut documentation - i don’t know, if glut supports this; but i can tell you, that using a “win32 console applikation” resulsts always in the appearance of this “nice, fancy & goodlooking” Win32 console window.
I have never heard of a way to avoid this.

If I understand correct, you have created a console application and would like to get rid of the console window?

If that is the case, simply call FreeConsole() which is defined in windows.h

The problem is you will still get a brief flash of the console window before it is closed down.

The only way to avoid the console entirely is by not creating a console app.

A Simple test app is:
#include <windows.h>

int main(int argc,char * argv[])
MessageBox(NULL,“Press OK to end”,“TEST”,MB_OK);
return 0;

The following code should do what you’re looking for. I don’t use GLUT often, so I have no idea if there are any side effects to doing this.

void init()
    HWND hWndCons = FindWindow(_T("ConsoleWindowClass"), NULL);
    if(hWndCons != NULL)
        ShowWindow(hWndCons, SW_HIDE);

    // other init stuff....

Hope this helps,

Yes that way works. Just by messing around I have found another way that also seems to work. So for anyone wondering here is what you can do. First you have to start vc++ and then say you want to make a windows application, not console app. Then select empty application. you must have a WinMain function but if you do this then everything will work correctly with glut.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)

glutInit( &nCmdShow, &lpCmdLine );

There is also a compiler setting you can add to prevent the console from popping up. I don’t remember what it was offhand, but I believe it is mentioned in the OpenGL FAQ. (Which you can get to from the little drop down in the upper left corner.)

#ifdef _WIN32
#pragma comment( linker, “/subsystem:“windows” /entry:“mainCRTStartup”” )

Hello mdog1234,

An easy approach I found was to, create a Win32 Application (Not Console) and change your main() function to this:


glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB );
//The rest of your code, and remember, do not add the glutInit function when working with Win32.

return 0;

To view a more explanatory descripition of this process, please view: http://www.opengl.org/discussion_boards/ubb/Forum10/HTML/000184.html

I hope this helps.

Edit: Sorry, I just read that you figured it out. So, don’t worry about this post.

  • VC6-OGL

[This message has been edited by VC6-OGL (edited 02-14-2003).]