I was wondering if anyone can tell me what is wrong with this code:
Basically the problem is this..... after the CreateWindow function I am checking to see if the hWindow is NULL and it is.Display_Windows_Error() is just a function to show me the what the error was. It calls GetLastError() function and FormatMessage() functions to tell me what went wrong. The error I am getting is "invalid Window Handle" and I can't figure out why. If anyone can tell me what is going wrong I would greatly appreciate it.Code:#include <windows.h> LRESULT CALLBACK WndProc(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam); void Display_Windows_Error(void); HINSTANCE hInstGlobal; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE PrevInstance, LPSTR lpCmdLine, int nShowCmd) { WNDCLASS WndClass; WndClass.style = 0; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.lpfnWndProc = WndProc; WndClass.hInstance = hInstance; WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); WndClass.hCursor = LoadCursor(NULL,IDC_ARROW); WndClass.hIcon = LoadIcon(NULL,IDI_APPLICATION); WndClass.lpszMenuName = 0; WndClass.lpszClassName = "WinProgram4"; if(RegisterClass(&WndClass) == 0) return(1); HWND hWindow; hWindow = CreateWindow(WinProgram4","Window", WS_OVERLAPPEDWINDOW,0,0 400,400,NULL,NULL,hInstance,NULL); if(hWindow == NULL) { Display_Windows_Error(); return(1); } ShowWindow(hWindow,nShowCmd); UpdateWindow(hWindow); MSG Message; while(GetMessage(&Message,NULL,0,0)) { DispatchMessage(&Message); } return(Message.wParam); }



LinkBack URL
About LinkBacks



