#include <Windows.h>
LRESULT CALLBACK WinProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
const LPWSTR szClassName = L"ClassName";
const LPWSTR szTitle = L"Window Tile";
int HEIGHT = 600;
int WIDTH = 800;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASSEX wc;
HWND hWnd = NULL;
MSG msg = {0};
wc.cbSize = sizeof ( WNDCLASSEX);
wc.hInstance = hInstance;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH) GetStockObject( NULL_BRUSH );
wc.hCursor = LoadCursor ( hInstance, IDC_CROSS );
wc.hIcon = LoadIcon ( NULL, MAKEINTRESOURCE(IDI_APPLICATION) );
wc.hIconSm = LoadIcon ( NULL, MAKEINTRESOURCE(IDI_WINLOGO) );
wc.lpfnWndProc = WinProc;
wc.lpszClassName = szClassName;
wc.lpszMenuName = NULL;
wc.style = CS_HREDRAW | CS_VREDRAW;
if ( !RegisterClassEx( &wc ) )
{
MessageBox(NULL,
L"Class Registration Failed",
L"Error:1",
NULL);
return 1;
}
hWnd = CreateWindow(
szClassName,
szTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
500, 100,
NULL,
NULL,
hInstance,
NULL
);
if (!hWnd)
{
MessageBox(NULL,
L"Call to CreateWindow failed!",
L"Error: 2",
NULL);
return 1;
}
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int)msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch( uMsg )
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
break;
case WM_CHAR:
switch( wParam )
{
case VK_ESCAPE:
PostQuitMessage(0);
return 0;
break;
}
default:
DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;
}
Ok, now when I debug, it fails to create the window, I know this is a nooby one but I really have no idea how to solve it, tryed to copy the CreateWindow() function from msdn(didn't help), so maybe its in WNDCLASSEX structure (didn't get any error when registering it..) , ... Anyone has any idea?