PDA

View Full Version : Disableing Console from appearing when using vc++ 6



mdog1234
02-05-2003, 10:43 PM
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.

DJSnow
02-06-2003, 01:40 AM
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.

02-06-2003, 05:31 AM
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[])
{
FreeConsole();
MessageBox(NULL,"Press OK to end","TEST",MB_OK);
return 0;
}

Dave.D
02-06-2003, 05:36 AM
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,
Dave

mdog1234
02-06-2003, 08:11 AM
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 );

Deiussum
02-06-2003, 12:43 PM
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.)

Defiance
02-13-2003, 10:48 PM
#ifdef _WIN32
#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
#endif

Stack Overflow
02-14-2003, 07:14 AM
Hello mdog1234,

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



int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int) {

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

glutMainLoop();
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).]