   Visual C++ 2005 to 2008 Woes
  Hello everyone,I am currently in the process of learning how to program in C++ and DirectX, so I picked up the book "Beginning Game Programming 2nd ed." However, I've run into a roadblock that I was hoping someone could help me with.Most of the code within the book was developed using Visual C++ 2005, but I downloaded 2008 since not only was 2005 no longer available on Microsoft's site, but I figured I might as well begin to get used to some of the newer development software. Unfortunately, the code does not work from 2005 to 2008. For the first few projects I had a work around by using different compilers, but for the one compiler that I found that did work, I don't believe there is any DirectX support for it. I don't want to further complicate the learning process by learning new code to get the old code to work, leaving me with two options:1) Find some sort of update for 2008 that will allow my 2005 code to work or2) Snoop around the net for Visual C++ 2005 somewhere.For reference, I will post the first simple "Hello World" program from the book as well as the compile errors it generates:// Beginning Game Programming// Chapter 3// WindowTest program//header files to include#include &lt;windows.h&gt;#include &lt;stdlib.h&gt;#include &lt;time.h&gt;//application title#define APPTITLE "Hello World"//function prototypes (forward declarations)BOOL InitInstance(HINSTANCE,int);ATOM MyRegisterClass(HINSTANCE);LRESULT CALLBACK WinProc(HWND,UINT,WPARAM,LPARAM);//the window event callback functionLRESULT CALLBACK WinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){PAINTSTRUCT ps;HDC hdc;char *szHello = "Hello World!";RECT rt;int x, y, n;COLORREF c;switch (message){case WM_PAINT://get the dimensions of the window  GetClientRect(hWnd, &rt);  //start drawing on device context  hdc = BeginPaint(hWnd, &ps);//draw some textDrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);//draw 1000 random pixelsfor (n=0; n&lt;3000; n++){x = rand() % (rt.right - rt.left);y = rand() % (rt.bottom - rt.top);c = RGB(rand()%256, rand()%256, rand()%256);SetPixel(hdc, x, y, c);}  //stop drawingEndPaint(hWnd, &ps);break;case WM_DESTROY:PostQuitMessage(0);break;    }    return DefWindowProc(hWnd, message, wParam, lParam);}//helper function to set up the window propertiesATOM MyRegisterClass(HINSTANCE hInstance){    //create the window class structure    WNDCLASSEX wc;    wc.cbSize = sizeof(WNDCLASSEX);//fill the struct with info    wc.style    = CS_HREDRAW | CS_VREDRAW;    wc.lpfnWndProc   = (WNDPROC)WinProc;    wc.cbClsExtra = 0;    wc.cbWndExtra = 0;    wc.hInstance= hInstance;    wc.hIcon    = NULL;    wc.hCursor  = LoadCursor(NULL, IDC_ARROW);    wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);    wc.lpszMenuName  = NULL;    wc.lpszClassName = APPTITLE;    wc.hIconSm  = NULL;    //set up the window with the class info    return RegisterClassEx(&wc);}//helper function to create the window and refresh itBOOL InitInstance(HINSTANCE hInstance, int nCmdShow){   HWND hWnd;   //create a new window   hWnd = CreateWindow(  APPTITLE,    //window class  APPTITLE,    //title bar  WS_OVERLAPPEDWINDOW,   //window style  CW_USEDEFAULT,    //x position of window  CW_USEDEFAULT,    //y position of window  500,    //width of the window  400,    //height of the window   NULL,   //parent window  NULL,   //menu  hInstance,   //application instance  NULL);  //window parameters   //was there an error creating the window?   if (!hWnd) return FALSE;   //display the window   ShowWindow(hWnd, nCmdShow);   UpdateWindow(hWnd);   return TRUE;}//entry point for a Windows programint WINAPI WinMain(HINSTANCE hInstance,    HINSTANCE hPrevInstance,    LPSTRlpCmdLine,    int  nCmdShow){    // declare variablesMSG msg;// register the classMyRegisterClass(hInstance);    // initialize applicationif (!InitInstance (hInstance, nCmdShow)) return FALSE;//set random number seedsrand(time(NULL));    // main message loopwhile (GetMessage(&msg, NULL, 0, 0)) {TranslateMessage(&msg);DispatchMessage(&msg);}return msg.wParam;}1&gt;------ Build started: Project: WindowTest, Configuration: Debug Win32 ------1&gt;Compiling...1&gt;main.cpp1&gt;c:\documents and settings\owner\my documents\visual studio 2008\projects\windowtest\windowtest\main.cpp(39) : error C2664: 'DrawTextW' : cannot convert parameter 2 from 'char *' to 'LPCWSTR'1&gt;   Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast1&gt;c:\documents and settings\owner\my documents\visual studio 2008\projects\windowtest\windowtest\main.cpp(78) : error C2440: '=' : cannot convert from 'const char [12]' to 'LPCWSTR'1&gt;   Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast1&gt;c:\documents and settings\owner\my documents\visual studio 2008\projects\windowtest\windowtest\main.cpp(102) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [12]' to 'LPCWSTR'1&gt;   Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast1&gt;c:\documents and settings\owner\my documents\visual studio 2008\projects\windowtest\windowtest\main.cpp(133) : warning C4244: 'argument' : conversion from 'time_t' to 'unsigned int', possible loss of data1&gt;Build log was saved at "file://c:\Documents and Settings\Owner\My Documents\Visual Studio 2008\Projects\WindowTest\WindowTest\Debug\BuildLog.htm"1&gt;WindowTest - 3 error(s), 1 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========Thank you for your time, and sorry for the very noobish question.[Edited by - PaladinJohn on May 16, 2009 5:13:06 PM]
  Quotes are nice, but source tags are better [smile]Having said that, it looks like you're trying to write code that uses the Multi-Byte Character Set, whereas your project is set to compile with the Unicode Character Set.  Basically this means that the compiler is interpreting "Hello World!" as a wchar_t*, but in your code you're trying to interpret it as a char*.  Either start using wide characters in your code or change your project to compile with the multi-byte character set by going to Project->Properties->General->Character Set and changing it from "Use Unicode Character Set" to "Use Multi-Byte Character Set".   ;  Thanks for the tips! I edited my original post to include source tags rather than quote.The program has successfully compiled.EDIT: Found out that I need to debug in Visual C++ in order to get the .exe to even appear. Sorry about all of the confusion, I'm used to Dev-C++ so toying around with Visual C++ was a learning experience in and of itself.   