Hiding the console?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Keanu

Hiding the console?

Post by Keanu »

I found the Irrlicht engine very interesting, but I don't like the output console wich gives me only error messages also if my game works well. There's a way to hide it? :D
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

yeah, just use WinMain() instead of main(). WinMain also takes some required paramaters I believe but can't remember them off the top of my head.
Keanu

Post by Keanu »

Thank I'm able to use the other parameters by myself.
I think you'll be my guru for the rest of my life
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

lol! you're very welcome. I'm actually a newbie to this myself :D
Keanu

Ooops

Post by Keanu »

I tried your solution but when I compile I get: "LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main". I think this is due to some project setting wich makes the application a console application and not a win32 app setting
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

to use INT WINAPI WinMain() in MSVC, you need to change to 'Release' mode.
a screen cap is worth 0x100000 DWORDS
MedievalMagic13

Post by MedievalMagic13 »

Are you sure you started a Win32 application instead of a Win32 console application? This might sound stupid, but I know lots of people (also myself) who have made mistakes in this. Maybe there is a parameter wrong or you forgot some. If I make a program without a console, I use this code (comes from DirectX8):

#define STRICT
#define WIN32_LEAN_AND_MEAN
#define INITGUID

#include <windows.h>
#include <mmsystem.h>

LRESULT CALLBACK WindowProc( HWND hWnd, UINT msg,
WPARAM wParam,
LPARAM lParam )
{
switch( msg )
{
case WM_KEYDOWN:
{
switch( wParam )
{
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
}
break;

case WM_CLOSE:
{
PostQuitMessage(0);
}

case WM_DESTROY:
{
PostQuitMessage(0);
}
break;

default:
{
return DefWindowProc (hWnd,msg,wParam, lParam );
}
break;
}

return 0;
}

//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
WNDCLASSEX winClass;
HWND hWnd;
MSG uMsg;

memset(&uMsg,0,sizeof(uMsg));

winClass.lpszClassName = "MY_WINDOWS_CLASS";
winClass.cbSize = sizeof(WNDCLASSEX);
winClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
winClass.lpfnWndProc = WindowProc;
winClass.hInstance = hInstance;
winClass.hIcon = LoadIcon(hInstance, (LPCTSTR) IDI_DIRECTX_ICON);
winClass.hIconSm = LoadIcon(hInstance, (LPCTSTR)IDI_DIRECTX_ICON);
winClass.hCursor = LoadCursor(NULL, IDC_ARROW);
winClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winClass.lpszMenuName = NULL;
winClass.cbClsExtra = 0;
winClass.cbWndExtra = 0;

if(!RegisterClassEx( &winClass) )
return E_FAIL;

hWnd = CreateWindowEx( NULL,"MY_WINDOWS_CLASS",
"Name of the project",
WS_OVERLAPPEDWINDOW, 0,0, 640,480, NULL, NULL,
hInstance, NULL );

if( hWnd == NULL )
return E_FAIL;

ShowWindow( hWnd, nCmdShow );
UpdateWindow( hWnd );



while( uMsg.message != WM_QUIT )
{
if( PeekMessage( &uMsg, NULL, 0, 0, PM_REMOVE ) )
{
TranslateMessage( &uMsg );
DispatchMessage( &uMsg );
}
else
{

render( hWnd );
}
}

shutDownD3D();

UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance );

return uMsg.wParam;
}




Sorry that the code looks a bit messy, but it should give you an idea about making a window. (Note that I only have experience with this in DirectX, not with Irrlicht).

I hope this will help you (a little).
qwe
Posts: 112
Joined: Sun Dec 28, 2003 12:54 am
Location: Oregon, USA

Post by qwe »

Yeah I forgot to mention that. Win32 application, not win32 console application :?
Keanu

You're right

Post by Keanu »

Yes I agree with all of you and I appreciate your ideas but the problem is i tryied many times to start a irrlicht application as a win32 app but it always says it can't execute. So I'm modifying the examples to make sure they works
Keanu

Finally the solution!

Post by Keanu »

Well implement the WinMain function as described before "INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE a, LPSTR strCmdLine,INT b)" then go to the project->settings... panel and in "c/c++" tab remove the pre-processor directive "_CONSOLE" and add "_WINDOWS", choose the "link" tab, and change "/SUBSYSTEM:console" to read "/SUBSYSTEM:windows", add your "WinMain()" and recompile. That's it!
MatKieng
Posts: 4
Joined: Tue Dec 30, 2003 9:47 am

Post by MatKieng »

My way to hide the cosole is pretty easy. First of all, create a new project, select the template as Win32Application (not Win32 console). And then, add new source file, just place

#include <Irrlicht.h>
#include <windows.h>

//Another statement, using namaspace for example

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)


in the body of WinMain fucntion, everything is the same as in the body of the main() function in the tutorials. Everything compiled OK. That's all.
[dx/x]=HUNT3R
Posts: 271
Joined: Sat Aug 23, 2003 5:52 pm
Location: Hurricane Central, Florida

Post by [dx/x]=HUNT3R »

keless wrote:to use INT WINAPI WinMain() in MSVC, you need to change to 'Release' mode.
No you don't, debug mode will work just fine...
keless
Posts: 805
Joined: Mon Dec 15, 2003 10:37 pm
Location: Los Angeles, California, USA

Post by keless »

ah. i guess i just have weird project settings then (I get compile errors trying to do it in Debug.. maybe i have one set to console and one to win32?)
a screen cap is worth 0x100000 DWORDS
R00mpel
Posts: 41
Joined: Sun Nov 09, 2003 10:12 am
Location: Russia, Nizhny Novgorod

Post by R00mpel »

Have you redefined the entry point of your program? It usually causes programs not to compile in debug mode...
The only thing to fear is running out of beer!
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

Post by DarkWhoppy »

In Dev-C+ all I did was create a new Win32 project and used "main()" ... no console. 8)
Post Reply