i am currently working with VC++ 6.0. i have just begun with it and wrote my first non-MFC code in it..however i have faced a problem in which my program terminates immediately on executing it..and i mean immediately..it doesnt even show the window that i create through that program..
however..later on i tested the ready made "Hello World" code..when i ran that code it worked fine and well...without any problem..
i dont know where i am stuck...my code is as follows :
#include <windows.h>
LRESULT CALLBACK WinProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain (HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszCmdArgs, int nWinMode)
{
MSG Msg;
WNDCLASS WinClass;
// WNDCLASSEX WinClass;
HWND hWnd;
WinClass.hInstance = hThisInst;
WinClass.lpszClassName = "Bhoot";
WinClass.lpfnWndProc = WinProc;
WinClass.style = 0;
// WinClass.cbSize = sizeof (WNDCLASSEX);
WinClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
if (!RegisterClass (&WinClass))
return 0;
hWnd = CreateWindow ( "Bhoot", "Bhoot", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, hThisInst, NULL);
// hWnd = CreateWindowEx ( NULL, "Bhoot", "Bhoot", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_DESKTOP, NULL, hThisInst, NULL);
ShowWindow (hWnd, nWinMode);
UpdateWindow (hWnd);
while ( GetMessage ( &Msg, NULL, NULL, NULL))
{
TranslateMessage (&Msg);
DispatchMessage ( &Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WinProc ( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_DESTROY :
PostQuitMessage (0);
break;
default :
return DefWindowProc (hWnd, Msg, wParam, lParam);
}
return 0;
}
can anyone explain me the reason and the solution to it?? :|