Problem with CreateWindowEx(..)! Please Help!
-
Well, while working on a class i am facing a really bad problem! well, i just cant get it! i just run the following code
BOOL COpenGLWindow::CreateOpenGLWindow(RECT Rect,char* WindowCaption,bool Fullscreen,int Bits,UINT ExStyle,UINT Style,HWND Parent) { WNDCLASS WndClass; WndClass.style=CS_VREDRAW|CS_HREDRAW|CS_OWNDC; WndClass.lpfnWndProc=OpenGLWndProc; WndClass.cbClsExtra=0; WndClass.cbWndExtra=0; WndClass.hInstance=GetInstHandle(); WndClass.hIcon=::LoadIcon(NULL,IDI_WINLOGO); WndClass.hCursor=::LoadCursor(NULL,IDC_ARROW); WndClass.hbrBackground=0; WndClass.lpszMenuName=0; WndClass.lpszClassName="OpenGLClass"; if(!RegisterClass(&WndClass)) { OutputDebugString(); return FALSE; } bool ShowWnd=(Style&WS_VISIBLE); Style|=~WS_VISIBLE; //AdjustWindowRectEx(&Rect,Style,FALSE,ExStyle); if(!(hWnd=CreateWindowEx(ExStyle,"OpenGLClass",WindowCaption,Style,Rect.left,Rect.top,Rect.right-Rect.left,Rect.bottom-Rect.top,Parent,(HMENU)NULL,GetInstHandle(),NULL))) { OutputDebugString(); return FALSE; } if(!(hDC=GetDC())) { OutputDebugString(); return FALSE; } PIXELFORMATDESCRIPTOR pfd= { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER, PFD_TYPE_RGBA, Bits, 0,0,0,0,0,0,0,0,0,0,0,0,0, 24, 0,0,0,0,0,0,0 }; int PixelFormat; if(!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) { OutputDebugString(); return FALSE; } if(!SetPixelFormat(hDC,PixelFormat,&pfd)) { OutputDebugString(); return FALSE; } if(!(hRC=wglCreateContext(hDC))) { OutputDebugString(); return FALSE; } if(!wglMakeCurrent(hDC,hRC)) { OutputDebugString(); return FALSE; } if(ShowWnd) { ShowWindow(hWnd,SW_SHOW); SetForegroundWindow(hWnd); SetFocus(hWnd); } return TRUE; }
and the call to CreateWindowEx Failes ! GetLastError() prints INvalid Window Handle.?!?!?!?:confused: well the call bieing made to this function is as follows:CreateOpenGLWindow(Rect,"Mine",false,16,WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,WS_POPUPWINDOW,NULL);
WEll i m in serious trouble so please help as soon as possible! shoaib. Doesn't Window Really Sucks!