This tells the operating system about your window
// use 'LoadImage' to load wnd class icon and cursor as it supercedes
// the obsolete functions 'LoadIcon' and 'LoadCursor', although these
// functions will still work. Because the icon and cursor are loaded
// from system resources ie they are shared, it is not necessary to
// free the image resources with either 'DestroyIcon' or 'DestroyCursor'.
hIcon=(HICON)LoadImage(0,IDI_APPLICATION,IMAGE_ICON,0,0,LR_SHARED);
hCursor=(HCURSOR)LoadImage(0,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED);
wcx.cbSize = sizeof(WNDCLASSEX); //byte size of WNDCLASSEX struct
wcx.style = CS_HREDRAW|CS_VREDRAW; //ensure wnd is always redrawn
wcx.lpfnWndProc = (WNDPROC)MainWndWndProc; //pointer to the Window Procedure
wcx.cbClsExtra = 0; //Extra bytes for 'class' wnds
wcx.cbWndExtra = 0; //Extra bytes for this wnd
wcx.hInstance = hInstance; //Application instance
wcx.hIcon = hIcon; //Application icon
wcx.hCursor = hCursor; //Cursor for wnd
wcx.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1); //Background wnd colour
wcx.lpszMenuName = TEXT("MainMenu"); //Name of window menu
wcx.lpszClassName = chClassName; //Name of this wnd 'class'
wcx.hIconSm = NULL; //Icon in top-left corner of wnd
//Register the wnd class with the Windows system
if (!RegisterClassEx(&wcx)) {
//Registration has failed so inform the user
MessageBox( NULL,
TEXT("Failed to register wnd class"),
TEXT("ERROR"),
MB_OK|MB_ICONERROR);
return FALSE;
}