Does not execute it for which reason?
I have written the following code to create a simple window. But the problem is that whenever I click execute button. It does not execute(run) it. It does nothing.
Please Note:
I am using Visual C++ 6 Enterprise, and every other program is executed except this one. I also copied and pasted the code from www.winpro.org to create a simple window and it works fine. Please find any error if you can.
Code:
#include <windows.h>
static char myclass[] = "t";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return WndProc(hwnd, msg, wparam, lparam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASSEX wc;
MSG message;
HWND hwnd;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.hInstance = hInstance;
wc.lpfnWndProc = WndProc;
wc.lpszMenuName = myclass;
wc.lpszMenuName = NULL;
wc.style = NULL;
if(!RegisterClassEx(&wc))
{
return 0;
}
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
myclass,
"This is win",
WS_OVERLAPPEDWINDOW,
0,
0,
100,
100,
NULL,
NULL,
hInstance,
NULL);
if(hwnd == NULL)
{
return 0;
}
ShowWindow(hwnd, nShowCmd);
UpdateWindow(hwnd);
while(GetMessage(&message, NULL, 0,0))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return message.wParam;
}
Thanks!:confused: