umarbzu
November 6th, 2003, 01:56 AM
Hi !!!
I am unable to create the window getting NULL in handle of window but when i tried to get the las error it give me zero error code plzzzzzzz help me
Here is the code
#include "windows.h"
#include "stdio.h"
//PROTOTYPES
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpInstance, LPSTR lpCmdLine, int nShowCmd);
ATOM InitApplication(HINSTANCE hInstance);
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
//EXECUTION POINT
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpInstance, LPSTR lpCmdLine, int nShowCmd)
{
if(!InitApplication(hInstance))
{
MessageBox(NULL,"Unable to register the window class","Registeration Error",MB_OK);
return (0);
}
HWND hTestWnd = CreateWindow("TEST",
"Test Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL
);
if(!hTestWnd)
{
DWORD Error = GetLastError();
char temp[50] = "";
sprintf(temp,"The Error Number is %d",Error);
MessageBox(NULL,temp,"Registeration Error",MB_OK);
return (0);
}
MSG msg;
// message loop
while(GetMessage(&msg,NULL,0,0))
{
DispatchMessage(&msg);
}
return (0);
}
ATOM InitApplication(HINSTANCE hInstance)
{
WNDCLASSEX wndcls;
wndcls.cbClsExtra = 0;
wndcls.cbSize = sizeof(wndcls);
wndcls.cbWndExtra = 0;
wndcls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndcls.hCursor = LoadCursor(hInstance,IDC_ARROW);
wndcls.hIcon = LoadIcon(hInstance,IDI_APPLICATION);
wndcls.hIconSm = NULL;
wndcls.hInstance = hInstance;
wndcls.lpfnWndProc = WndProc;
wndcls.lpszClassName = "TEST";
wndcls.lpszMenuName = NULL;
wndcls.style = 0;
return (RegisterClassEx(&wndcls));
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
DefWindowProc(hWnd,Message,wParam,lParam);
return (0);
}
I am unable to create the window getting NULL in handle of window but when i tried to get the las error it give me zero error code plzzzzzzz help me
Here is the code
#include "windows.h"
#include "stdio.h"
//PROTOTYPES
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpInstance, LPSTR lpCmdLine, int nShowCmd);
ATOM InitApplication(HINSTANCE hInstance);
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam);
//EXECUTION POINT
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hpInstance, LPSTR lpCmdLine, int nShowCmd)
{
if(!InitApplication(hInstance))
{
MessageBox(NULL,"Unable to register the window class","Registeration Error",MB_OK);
return (0);
}
HWND hTestWnd = CreateWindow("TEST",
"Test Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
0,
CW_USEDEFAULT,
0,
NULL,
NULL,
hInstance,
NULL
);
if(!hTestWnd)
{
DWORD Error = GetLastError();
char temp[50] = "";
sprintf(temp,"The Error Number is %d",Error);
MessageBox(NULL,temp,"Registeration Error",MB_OK);
return (0);
}
MSG msg;
// message loop
while(GetMessage(&msg,NULL,0,0))
{
DispatchMessage(&msg);
}
return (0);
}
ATOM InitApplication(HINSTANCE hInstance)
{
WNDCLASSEX wndcls;
wndcls.cbClsExtra = 0;
wndcls.cbSize = sizeof(wndcls);
wndcls.cbWndExtra = 0;
wndcls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndcls.hCursor = LoadCursor(hInstance,IDC_ARROW);
wndcls.hIcon = LoadIcon(hInstance,IDI_APPLICATION);
wndcls.hIconSm = NULL;
wndcls.hInstance = hInstance;
wndcls.lpfnWndProc = WndProc;
wndcls.lpszClassName = "TEST";
wndcls.lpszMenuName = NULL;
wndcls.style = 0;
return (RegisterClassEx(&wndcls));
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
DefWindowProc(hWnd,Message,wParam,lParam);
return (0);
}