   Windows Programming
  Hi,   I'm not sure if this is the right place to post this but its too late now!!! :)I have some code here which builds a simple Win32 window, I doesn't seem to compile, but it is code which i have copied from a sample from a book. And the file i copied it from compiles fine (thats probably wasn't the best way of explaining it).I am using Visual C++ Express Edition (I have setup the PSDK). I was wondering if someone could either suggest wether their are any errors in the source code(Below) or whether i have missed something in setting up the compiler.#include <windows.h>#include <stdio.h>#include <d3d9.h>// Window handles, class and caption textHWNDg_hWnd;HINSTANCEg_hInst;static char   g_szClass[]   = "ShellClass";static char   g_szCaption[] = "Shell Application";// Function prototypesint PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev,    LPSTR szCmdLine, int nCmdShow);long FAR PASCAL WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);BOOL DoInit();BOOL DoShutdown();BOOL DoFrame();int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev,    LPSTR szCmdLine, int nCmdShow){  WNDCLASSEX wcex;  MSG   Msg;  g_hInst = hInst;  // Create the window class here and register it  wcex.cbSize   = sizeof(wcex);  wcex.style    = CS_CLASSDC;  wcex.lpfnWndProc   = WindowProc;  wcex.cbClsExtra    = 0;  wcex.cbWndExtra    = 0;  wcex.hInstance= hInst;  wcex.hIcon    = LoadIcon(NULL, IDI_APPLICATION);  wcex.hCursor  = LoadCursor(NULL, IDC_ARROW);  wcex.hbrBackground = NULL;  wcex.lpszMenuName  = NULL;  wcex.lpszClassName = g_szClass;  wcex.hIconSm  = LoadIcon(NULL, IDI_APPLICATION);  if(!RegisterClassEx(&wcex))    return FALSE;  // Create the Main Window  g_hWnd = CreateWindow(g_szClass, g_szCaption,   WS_CAPTION | WS_SYSMENU,   0, 0, 400, 400,   NULL, NULL,   hInst, NULL );  if(!g_hWnd)    return FALSE;  ShowWindow(g_hWnd, SW_NORMAL);  UpdateWindow(g_hWnd);  // Run init function and return on error  if(DoInit() == FALSE)    return FALSE;  // Start message pump, waiting for signal to quit  ZeroMemory(&Msg, sizeof(MSG));  while(Msg.message != WM_QUIT) {    if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&Msg; DispatchMessage(&Msg;    }    if(DoFrame() == FALSE) break;  }  // Run shutdown function  DoShutdown();    UnregisterClass(g_szClass, hInst);  return Msg.wParam;}long FAR PASCAL WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam){  switch(uMsg) {    case WM_DESTROY: PostQuitMessage(0); return 0;  }  return DefWindowProc(hWnd, uMsg, wParam, lParam);}BOOL DoInit(){  return TRUE;}BOOL DoShutdown(){  return TRUE;}BOOL DoFrame(){  return TRUE;}I am relatively new to programming so you may need to dumb your replies down a bit or explain it detail so i understand. :)Cheers Jozers   
  Moved to the For Beginners forum.   ;  Thanks;  It might help if you posted the errors you are getting.;  Here is the Error:------ Build started: Project: Project3D, Configuration: Debug Win32 ------Compiling...WinMain.cppc:\documents and settings\user.e-097c75159d2a4\my documents\visual studio 2005\projects\project3d\project3d\winmain.cpp(43) : error C2440: '=' : cannot convert from 'char [11]' to 'LPCWSTR'   Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style castc:\documents and settings\user.e-097c75159d2a4\my documents\visual studio 2005\projects\project3d\project3d\winmain.cpp(53) : error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [11]' to 'LPCWSTR'   Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style castc:\documents and settings\user.e-097c75159d2a4\my documents\visual studio 2005\projects\project3d\project3d\winmain.cpp(77) : error C2664: 'UnregisterClassW' : cannot convert parameter 1 from 'char [11]' to 'LPCWSTR'   Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style castc:\documents and settings\user.e-097c75159d2a4\my documents\visual studio 2005\projects\project3d\project3d\winmain.cpp(79) : warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of datac:\documents and settings\user.e-097c75159d2a4\my documents\visual studio 2005\projects\project3d\project3d\winmain.cpp(92) : warning C4244: 'return' : conversion from 'LRESULT' to 'long', possible loss of dataBuild log was saved at "file://c:\Documents and Settings\User.E-097C75159D2A4\My Documents\Visual Studio 2005\Projects\Project3D\Project3D\Debug\BuildLog.htm"Project3D - 3 error(s), 2 warning(s)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========;  The errors you are getting is due to the fact that VC++ 2005 express expect you to use wide character strings by default.You can turn this option off if you go to project -> properties -> configuration properties -> general, and set Character set = Not setAnother option is to convert your strings to wide character strings, but the above is easier IMO;  Or wrap your strings in _T(), like _T("Some String")   ;  Thanks so much pulpfist and Mite51 that seems to solve the problem.   