Error 2 and 183 while registering a windowe class and creatinga window.

Hi all

when i try to register a new Window Class, I get the Errors no 2 and 183

Error 2: The system cannot find the file specified.
Error 183 : Cannot create a file when that file already exists.

Following is the Code thats creatting these errors:

LRESULTCALLBACKWndProc(HWNDhwnd,UINTiMsg,

WPARAMwParam,LPARAMlParam) {

switch (iMsg) {

}

return 0;

}

intAPIENTRYWinMain(HINSTANCEhInstance,

HINSTANCEhPrevInstance,

LPSTRlpCmdLine,

intnCmdShow)

{

WNDCLASSwndclass;

HMODULEhmod =GetModuleHandle(NULL);

wndclass.style = 0;

wndclass.lpfnWndProc =WndPro;

wndclass.cbClsExtra = 0;

wndclass.cbWndExtra = 0;

wndclass.hInstance =hmod;

wndclass.hIcon =NULL;

wndclass.hCursor =NULL;wndclass.hbrBackground = (HBRUSH)(COLOR_BACKGROUND+1);

wndclass.lpszMenuName =NULL;

wndclass.lpszClassName = (char *)"SK\0";

ATOMwndclassatom =RegisterClass(&wndclass);

DWORD hError1=GetLastError(); //Error : 2

WNDCLASSWndClass_info;

BOOLstatus =GetClassInfo(hInstance,

(LPCSTR)(LOWORD(wndclassatom)),
&WndClass_info);

//Status comes out to be same as the ATOM.

HWNDhWindow=CreateWindow("SK\0",

NULL,WS_VISIBLE|WS_VSCROLL|WS_MAXIMIZE|WS_THICKFRAME,

50,50,500,500,

NULL,

NULL,

hmod,

NULL);

DWORDhError=GetLastError();//Error :183

ShowWindow(hWindow, 1);

UpdateWindow(hWindow);

SetWindowText(hWindow,"This is test message");

Sleep(5000);

UnregisterClass("SK",hInstance);

return 0;

}

Any help is really appreciated.

Thanks a lot..
Sumit Chawla

[4857 byte] By [SumitChawla] at [2008-3-5]
# 1
You need to deal with the WM_NCCREATE message in your WndProc. It should return 1 to continue. You can just let DefWindowProc deal with it.
daveme at 2007-9-9 > top of Msdn Tech,Software Development for Windows Vista,General Windows Vista Development Issues...

Software Development for Windows Vista

Site Classified