   Help me with my Win32 code
  I cant seem to get any of my win32 code to work.  I am trying to write a Game Window class that encapsulates some win32 window functions and window initiallization.  I am very new to win32 and I am having a ton of problemsI have a function in my GameWindowManagerClass called CreateGameWindow:Header:HRESULT GameWindowManager::CreateGameWindow(HINSTANCE instance, BaseGameWindow** window, struct GameOptions* const options)the function is bug filled and I have managed to debug part of it but now I am stuck on a section that looks like this:WNDCLASSEX wndClass;memset( &wndClass, 0, sizeof(WNDCLASSEX) );wndClass.hInstance = instance;wndClass.cbSize = sizeof(WNDCLASSEX);wndClass.lpfnWndProc = &(BaseGameWindow::WndProc);wndClass.lpszClassName = GameLib::WindowClassName;wndClass.style = CS_VREDRAW | CS_HREDRAW;if( FAILED(RegisterClassEx( &wndClass ))){throw("failed to register window class");}memset( &((*window)->windowProps) , 0, sizeof( (*window)->windowProps) );HWND hWnd = CreateWindowEx(0,   GameLib::WindowClassName,   _T("Window Name"),   WS_OVERLAPPEDWINDOW,    CW_USEDEFAULT,   CW_USEDEFAULT,    640,   800,   GetDesktopWindow(),   NULL,   instance,   0);if(!(*window)->windowProps.HWnd){throw("HWnd not valid");}I am pretty sure that the problem lies in the part where I call CreateWindowEx().  What is wrong with my code?EDIT:also, are there any ways to improve my style?  I don't think that this line:memset( &((*window)->windowProps) , 0, sizeof( (*window)->windowProps) );looks very good but I dont know how to avoid the nasty looking syntax.   
  Did you try calling GetLastError() to find out what the error is?   ;  sorry I am really stupid.  the real code is this:(*window)->windowProps.HWnd = CreateWindowEx(0, GameLib::WindowClassName, _T("Window Name"), WS_OVERLAPPEDWINDOW,  CW_USEDEFAULT, CW_USEDEFAULT,  640, 800, GetDesktopWindow(), NULL, instance, 0);notHWND hWnd = CreateWindowEx(0,   GameLib::WindowClassName,   _T("Window Name"),   WS_OVERLAPPEDWINDOW,    CW_USEDEFAULT,   CW_USEDEFAULT,    640,   800,   GetDesktopWindow(),   NULL,   instance,   0);I was trying to debug it and forgot to destroy the temporary HWND.  The problem still exists;  Encapsulating a Win32 window is not that complicated.Place an HWND in your class as a private member.Define an instance-specific window message handler as a normal object method.In your class constructor, fill out a WNDCLASS (or, preferably, a WNDCLASSEX) with the lpfnWndProc member assigned to a static function of your class. We will call this static function your router function. Then call CreateWindow (or, preferably, CreateWindowEx), passing this as the lpParam argument.In your router function, check if the current message is, say, WM_NCCREATE - really, any of the messages sent before WM_CREATE will do - and associate the pointer to your window class instance, the one passed in as the lpParam argument, with the HWND by calling SetWindowLongPtr. For all other messages, check if there is an associated handle (if the result of GetWindowLongPtr is not null, cast it to a pointer to your window class), and call the instance-specific message handler on it.Here's an article covering one approach.Here's another.   ;Quote:Original post by jdubI am pretty sure that the problem lies in the part where I call CreateWindowEx().What does CreateWindowEx return?What does you window callback procedure look like?;  Maybe I'm missing it, but I don't see where you ever say what the problem is, other than being "bug filled".   