Hello!
I have some problems compiling my DX window in Visual Studio 2005 Beta 2:
------ Build started: Project: example1, Configuration: Debug Win32 ------
Compiling...
winmain.cpp
c:\documents and settings\øyvind ege\mine dokumenter\visual studio 2005\projects\example1\example1\winmain.cpp(12) : error C2065: 'WndProc' : undeclared identifier
c:\documents and settings\øyvind ege\mine dokumenter\visual studio 2005\projects\example1\example1\winmain.cpp(20) : error C2440: '=' : cannot convert from 'const char [15]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\øyvind ege\mine dokumenter\visual studio 2005\projects\example1\example1\winmain.cpp(24) : error C2065: 'wndHandle' : undeclared identifier
c:\documents and settings\øyvind ege\mine dokumenter\visual studio 2005\projects\example1\example1\winmain.cpp(24) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [15]' to 'LPCWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
c:\documents and settings\øyvind ege\mine dokumenter\visual studio 2005\projects\example1\example1\winmain.cpp(34) : error C2365: 'WndProc' : redefinition; previous definition was 'formerly unknown identifier'
c:\documents and settings\øyvind ege\mine dokumenter\visual studio 2005\projects\example1\example1\winmain.cpp(45) : warning C4007: 'WinMain' : must be '__stdcall'
c:\documents and settings\øyvind ege\mine dokumenter\visual studio 2005\projects\example1\example1\winmain.cpp(55) : error C2143: syntax error : missing ')' before '{'
c:\documents and settings\øyvind ege\mine dokumenter\visual studio 2005\projects\example1\example1\winmain.cpp(55) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Build log was saved at "file://c:\Documents and Settings\Øyvind Ege\Mine dokumenter\Visual Studio 2005\Projects\example1\example1\Debug\BuildLog.htm"
example1 - 7 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
And here's my code:
#include <windows.h>
HINSTANCE hInst;
HWND wnHandle;
bool initWindow( HINSTANCE hInstance )
{
WNDCLASSEX wcex;
wcex.cbSize =sizeof( WNDCLASSEX );
wcex.style =CS_HREDRAW| CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = "DirectXExample";
wcex.hIconSm = 0;
RegisterClassEx(&wcex);
wndHandle = CreateWindow("DirectXExample", "DirectXExample",WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL);
if(!wndHandle)
return false;
ShowWindow(&wndHandle, SW_SHOW);
UpdateWindow(wndHandle);
return true;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
if (!initWindow(hInstance) )
return false;
MSG msg;
ZeroMemory( &msg, sizeof(msg ) );
while( msg.message!=WM_QUIT)
{
while (GetMessage(&msg, wndHandle, 0, 0)
{
TranslateMessage(&msg);
DispatchMessage8&msg);
}
}
return (int) msg.wParam;
}
Thanks for any help!
Hope I was helpful. And thank you if you were!