Hi All,
I am very new to VC++ programming. I tried to create a window. That's all. I wrote a program and it runs but doesn't shows the window. When I tried to Build it again it needs the exe file to overwrite it. But since the window is invisible and it has not ended, VC++ compiler says that
fatal error LNK1168: cannot open Debug/test.exe for writing.
I will paste code here
Code:
#include<windows.h>
long _stdcall WndProc(HWND,UINT,UINT,long);
WNDCLASS wndclass;
int _stdcall WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,char *CmdLine,int nCmdShow)
{
HWND hwnd;
MSG msg;
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=WndProc;
wndclass.lpszClassName="My Class";
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
RegisterClass(&wndclass);
hwnd=CreateWindow("My Class","First Window",WS_OVERLAPPEDWINDOW,20,20,100,100,0,0,hInstance,0);
ShowWindow(hwnd,nCmdShow);
while(GetMessage(&msg,0,0,0))
{
DispatchMessage(&msg);
}
return 0;
}
long _stdcall WndProc(HWND hwnd,UINT x ,UINT y,long z)
{
switch(x)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
DefWindowProc(hwnd,x,y,z);
}
return 0L;
}