-
Odd windows problem
I was creating a basic window, and when I tried to compile it I got these errors
Code:
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
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);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
//Initialize the window
if(!InitWindow)
return false;
//Main message loop
MSG msg = {0};
while(msg.message != WM_QUIT)
{
while(PeekMessage(&msg, wndHandle, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
//Aditional game logic can go here
}
return msg.message;
}
//InitWindow
bool InitWindow(HINSTANCE hInstance, int width, int height)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = 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;
RegisterClass(&wcex);
//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 - rect.top, NULL, NULL, hInstance, NULL);
if(!wndHandle)
return false;
//Display the window on the screen
ShowWindow(wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
return true;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
//Check the message queue
switch(message)
{
case WM_KEYDOWN:
switch(wParam)
{
//Check if the user hit the Escape Key
case VK_ESCAPE:
PostQuitMessage(0);
break;
}
break;
//The user hit the close button, close the application
case WM_DESTROY:
PostQuitMessage(0);
break;
}
//Always return the message to the default window procedure for further processing
return DefWindowProc(hWnd, message, wParam, lParam);
}
Thank you in advance.
-
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
Niara
-
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.
-
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...