Thread: Odd windows problem

  1. #1
    Registered User
    Join Date
    Nov 2009

    Odd windows problem

    I was creating a basic window, and when I tried to compile it I got these errors

    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\objidl.h(11280): error C2061: syntax error : identifier '__RPC__out_xcount_part'
    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\objidl.h(11281): error C2059: syntax error : ')'
    c:\program files (x86)\microsoft sdks\windows\v7.0a\include\objidl.h(11281): fatal error C1903: unable to recover from previous error(s); stopping compilation
    Here is my code

    //Include the windows header files
    #include <Windows.h>
    HINSTANCE hInst;
    HWND wndHandle;
    int width = 640;
    int Height = 480; 
    //Forward declerations
    bool InitWindow(HINSTANCE hInstance, int width, int height);
    int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
    	//Initialize the window
    		  return false;
    	//Main message loop
    	MSG msg = {0};
    	while(msg.message != WM_QUIT)
    		while(PeekMessage(&msg, wndHandle, 0, 0, PM_REMOVE))
    		//Aditional game logic can go here
    	return msg.message;
    bool InitWindow(HINSTANCE hInstance, int width, int height)
    	WNDCLASSEX wcex;
    	wcex.cbSize = sizeof(WNDCLASSEX); = CS_HREDRAW | CS_VREDRAW;
    	wcex.lpfnWndProc = WndProc;
    	wcex.cbClsExtra = 0;
    	wcex.cbWndExtra = 0;
    	wcex.hInstance = hInstance;
    	wcex.hIcon = 0;
    	wcex.hCursor = LoadCursor(hInstance, IDC_ARROW);
    	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    	wcex.lpszMenuName = NULL;
    	wcex.lpszClassName = TEXT("DirectXExample");
    	wcex.hIconSm = 0;
    	//Resize the window
    	RECT rect = {0, 0, width, height};
    	AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
    	//Creaete the window from the class above
    	wndHandle = CreateWindow(TEXT("DirectXExample"), TEXT("DirectXExample"), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left,
    		rect.bottom -, NULL, NULL, hInstance, NULL);
    		return false;
    	//Display the window on the screen
    	ShowWindow(wndHandle, SW_SHOW);
    	return true;
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    	//Check the message queue
    	case WM_KEYDOWN:
    			//Check if the user hit the Escape Key
    		case VK_ESCAPE:
    		//The user hit the close button, close the application
    	case WM_DESTROY:
    	//Always return the message to the default window procedure for further processing
        return DefWindowProc(hWnd, message, wParam, lParam);
    Thank you in advance.

  2. #2
    Registered User
    Join Date
    Mar 2005
    I'm not sure about your code, if you have solved the problem then omit my comment; I have done only an overview, and find 2 things: you are calling a function without parentheses (and without arguments) on line 16, you should pass the arguments to the function is expected to get; the second is that you are using a wrong struct type while registering class in line 52, take a look at MSDN->RegisterClass and see what struct is expecting, also take a look at RegisterClassEx

    Also a simple observation: why do you declare a variable 'width' and then 'Height'? (Note the capitalize); it's only for code presentation purposes, since both are at the same 'level', why you don't write them on the same format?

    Hope that helps

  3. #3
    Registered User
    Join Date
    Mar 2011
    What sort of project type are you using, a win32, .net, or managed. I only use win32 projects, but that looks like it is using some interface related stuff, i.e. COM objects. But an undefined error in a windows header most probably indicates a '#define' error. You should get an error for calling RegisterClass with an 'WNDCLASSEX' structure and the 'InitWindow' just as Niara said. They just don't make it to compilation.

    Use lower case windows '#include <windows.h>'

    and try preceeding it with '#define _WIN32_WINNT 0x600'

    or whatever version is applicable to windows 7 > than 0x600 if any.

  4. #4
    Registered User
    Join Date
    Mar 2011
    i once had the same problem, after i installed directx sdk. if you have another sdk installed, such as directx, you should check the include directories (tools>options>project and solutions>VC++ directories - for VC++) and make sure the standart windows directories come first, not the other ones.

    i hope it helps...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 03:25 AM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  3. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM
  4. Application Termination Problem in Windows XP
    By wasabee in forum Windows Programming
    Replies: 2
    Last Post: 04-11-2003, 12:53 PM
  5. C++ Gurus, UNIX vs. Windows ascii problem perhaps?
    By puck in forum C++ Programming
    Replies: 6
    Last Post: 03-28-2003, 09:33 PM