[CODE=c]
#include <windows.h>
#include <time.h>
#define WIDTH 320
#define HEIGHT 240
LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTAN CE hInstance, HINSTANCE hPrev, LPSTR CmdLine, int CmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASSEX wc;
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WinProc;
wc.cbWndExtra = 0;
wc.cbClsExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL , IDC_ARROW);
wc.hbrBackgroun d = (HBRUSH) GetStockObject( WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassNam e ="wndclass";
wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
if(!RegisterCla ssEx(&wc))
{
MessageBox(NULL ,"Failed to register window","ERROR! ",MB_OK|MB_ICON EXCLAMATION);
return EXIT_FAILURE;
}
hWnd = CreateWindow("w ndclass",
"HPEN-Ayan",
WS_OVERLAPPEDWI NDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
WIDTH,
HEIGHT,
NULL,
NULL,
hInstance,
NULL);
if(!hWnd)
{
MessageBox(NULL ,"Failed to create window","ERROR! ",MB_OK|MB_ICON EXCLAMATION);
return EXIT_FAILURE;
}
ShowWindow(hWnd , CmdShow);
while(GetMessag e(&msg, NULL, 0, 0))
{
if(msg.message = WM_QUIT)
break;
TranslateMessag e(&msg);
DispatchMessage (&msg);
}
UnregisterClass ("wndclass", hInstance);
return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
...
}
[/CODE]
now can some one tell me why this progrm is gettn stucked at CreateWindow() as it cannot get a handle to the window....so according to my prog...its giving a messagebox "Failed to create window"...
#include <windows.h>
#include <time.h>
#define WIDTH 320
#define HEIGHT 240
LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTAN CE hInstance, HINSTANCE hPrev, LPSTR CmdLine, int CmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASSEX wc;
wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = WinProc;
wc.cbWndExtra = 0;
wc.cbClsExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL , IDC_ARROW);
wc.hbrBackgroun d = (HBRUSH) GetStockObject( WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassNam e ="wndclass";
wc.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
if(!RegisterCla ssEx(&wc))
{
MessageBox(NULL ,"Failed to register window","ERROR! ",MB_OK|MB_ICON EXCLAMATION);
return EXIT_FAILURE;
}
hWnd = CreateWindow("w ndclass",
"HPEN-Ayan",
WS_OVERLAPPEDWI NDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
WIDTH,
HEIGHT,
NULL,
NULL,
hInstance,
NULL);
if(!hWnd)
{
MessageBox(NULL ,"Failed to create window","ERROR! ",MB_OK|MB_ICON EXCLAMATION);
return EXIT_FAILURE;
}
ShowWindow(hWnd , CmdShow);
while(GetMessag e(&msg, NULL, 0, 0))
{
if(msg.message = WM_QUIT)
break;
TranslateMessag e(&msg);
DispatchMessage (&msg);
}
UnregisterClass ("wndclass", hInstance);
return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
...
}
[/CODE]
now can some one tell me why this progrm is gettn stucked at CreateWindow() as it cannot get a handle to the window....so according to my prog...its giving a messagebox "Failed to create window"...
Comment