   Help! Please!
  Okay so I decide to start programming again, crack open this new DirectX book and start working away at it.Well I can't even get this easy code to compile, I have no idea what I've done wrong the code looks all the same from out of the book. Perhaps one of you could tell me I'm a bumbling idiot, and missed a semi colon or something. Here is the code and the errors.// Include the Windows header file that's needed for all Windows applications#include <windows.h>HINSTANCE hInst;//global handle to hold the application instanceHWND wndHandle;//global variable to hold the window handle// forward declarationsbool initWindow( HINSTANCE hInstance );LRESULT CALLBACK WndProc( HWND, UINT, WPARAM, LPARAM );// This is winmain, the main entry point for Windows applicationsint WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ){// Initialize the windowif ( !initWindow( hInstance ) )return false;/*This is the main message loop. It is the most important part of your WinMain function as it is what parses all the messagesthat our program receives from windows.*/// main message loop:MSG msg;ZeroMemory( &msg, sizeof( msg ) );while( msg.message!=WM_QUIT ){// Check the message queuewhile (GetMessage(&msg, wndHandle, 0, 0)){TranslateMessage( &msg );DispatchMessage( &msg );}}return (int) msg.wParam;}/**************************************************************************************** bool initWindow( HINSTANCE hInstance )* initWindow registers the window class for the application, creates the window****************************************************************************************/bool initWindow( HINSTANCE hInstance ){WNDCLASSEX wcex;// Fill in the WNDCLASSEX structure. This describes how the window// will look to the systemwcex.cbSize= sizeof(WNDCLASSEX);// the size of the structurewcex.style= CS_HREDRAW | CS_VREDRAW;// the class stylewcex.lpfnWndProc= (WNDPROC)WndProc;// the window procedure callbackwcex.cbClsExtra= 0;// extra bytes to allocate for this classwcex.cbWndExtra= 0;// extra bytes to allocate for this instancewcex.hInstance= hInstance;// handle to the application instancewcex.hIcon= 0;// icon to associate with the applicationwcex.hCursor= LoadCursor(NULL, IDC_ARROW);// the default cursorwcex.hbrBackground= (HBRUSH)(COLOR_WINDOW+1);// the background colorwcex.lpszMenuName= NULL;// the resource name for the menuwcex.lpszClassName= "DirectXExample";// the class name being createdwcex.hIconSm= 0;// the handle to the small iconRegisterClassEx(&wcex);// Create the windowwndHandle = CreateWindow("DirectXExample",// the window class to use"DirectXExample",// the title bar textWS_OVERLAPPEDWINDOW,// the window styleCW_USEDEFAULT,// the starting x coordinateCW_USEDEFAULT,// the starting y coordinate640,// the pixel width of the window480,// the pixel height of the windowNULL,// the parent window; NULL for desktopNULL,// the menu for the application; NULL for// nonehInstance,// the handle to the application instanceNULL);// no values passed to the window// Make sure that the window handle that is created is validif (!wndHandle)return false;// Display the window on the screenShowWindow(wndHandle, SW_SHOW);UpdateWindow(wndHandle);return true;}/*********************************************************************************************** LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)* The window procedure***********************************************************************************************/LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){// Check any available messages from the queueswitch (message){case WM_DESTROY:PostQuitMessage(0);break;}// Always return the message to the default window// procedure for further processingreturn DefWindowProc(hWnd, message, wParam, lParam);}And the errors are as followsQuote:------ Build started: Project: example1, Configuration: Debug Win32 ------Compiling...winmain.cppc:\documents and settings\johnathan\my documents\visual studio 2005\projects\beginningdirectx9\example1\example1\winmain.cpp(13) : error C2731: 'WinMain' : function cannot be overloaded   c:\documents and settings\johnathan\my documents\visual studio 2005\projects\beginningdirectx9\example1\example1\winmain.cpp(12) : see declaration of 'WinMain'c:\documents and settings\johnathan\my documents\visual studio 2005\projects\beginningdirectx9\example1\example1\winmain.cpp(59) : 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 castc:\documents and settings\johnathan\my documents\visual studio 2005\projects\beginningdirectx9\example1\example1\winmain.cpp(76) : 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 castBuild log was saved at "file://c:\Documents and Settings\Johnathan\My Documents\Visual Studio 2005\Projects\BeginningDirectX9\example1\example1\Debug\BuildLog.htm"example1 - 3 error(s), 0 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  Just by going on the error mentioning "CreateWindowExW", I'd say your project settings are set to use wide characters rather than ANSI.  That would explain why it's not liking your WinMain declaration either.Under Visual C++ 2005, open the Properties for the project and change "Configuration Properties" -> "General" -> "Character Set" to "Not Set".   ;  Halleluja! Thank you!I would have never found that, is that like a default setting for Microsoft Visual Studios 2005? This is the first time I'm really finally gotten to sit down and use it since I got it. Is there any other gotcha's I should know about?   ;  Normally, no, it's not a default setting.  If you loaded a pre-made project file, then it might have been set by someone else (although the source code wasn't adjusted to match)...There are always gotchas.  :)  I can't really think of anything else off hand, but if you run into something else, feel free to post -- we'll try to help out.   ;  Hey! I'm pretty sure I followed all these steps correctly.So I have modified my code abit to include directx9 stuff.Now I went and added two directories, one was the include directory for the directx 9 sdk and the other was the lib directory at directxsdk\lib\x86Then under Linker I go and add d3d9.lib to the list of dependencies. But when I try to compile I get an unable to open file error message. It's having troubles opening d3d9.lib. I made sure there was a d3d9.lib file included in the directory. It is there I don't know what step I missed.   ;  did you go and find that file directly?  To make sure that is the correct path, or did you type that from the book?  If you typed that from the book, you might have a different version of DX9 (there are lots).  Mine is the Feb2k6 release and its in "c:\program files\Microsoft DirectX SDK (February 2006)" directory.   ;  Yea, my problem was I didn't do it correctly. I was doing it for project only. So i decided to close the solution and do the directories that way. It all works now thank you!   