Hiding the console?
-
Keanu
Hiding the console?
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? 
-
Keanu
-
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).
#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).
-
Keanu
You're right
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!
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!
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.
#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
-
DarkWhoppy
- Posts: 386
- Joined: Thu Sep 25, 2003 12:43 pm
- Contact: