I just got Microsoft Visual Studio 2005 and I can't make even really basic programs (Win32) to compile. I tried to compile a program that in Visual C++ 6.0 has 0 errors and 0 warnings, but in this new version that doesn't happen. The short program named 'main.cxx' is:
#include<windows.h>
long FAR PASCAL WndProc (HWND hwnd, UINT message,
UINT wParam, LONG lParam)
{
static HWND ewin;
switch (message)
{
case WM_CREATE:
{
ewin = CreateWindowEx(0,"button","Exit",
WS_CHILD | WS_VISIBLE | SS_CENTER,
0,400,400,60,
hwnd,(HMENU)2,
(HINSTANCE)GetWindowLong(hwnd,GWL_HINSTANCE),
NULL);
return 0;
}
break;
case WM_COMMAND:
{
switch (wParam)
{
case 2:
PostQuitMessage (0);
break;
}
return 0;
}
break;
case WM_DESTROY:
{
PostQuitMessage (0);
return 0;
}
break;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}
int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdParam, int nCmdShow)
{
static char szAppName[] = "Win32Cone";
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.lpszMenuName = NULL;
wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.lpszClassName = szAppName;
RegisterClass (&wndclass);
}
hwnd = CreateWindowEx ( 0,szAppName,
"Draw Window",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
400,
480,
NULL,
NULL,
hInstance,
NULL);
ShowWindow (hwnd, nCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
and the errors are:
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [7]' to 'LPCWSTR'
error C2440: '=' : cannot convert from 'char [10]' to 'LPCWSTR', Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'char [10]' to 'LPCWSTR'
and I get some warnings like:
warning C4312: 'type cast' : conversion from 'LONG' to 'HINSTANCE' of greater size
I see that the errors are related to the way the characters are interpreted, that is when I use ' char array[] = "WindowName" ' in CreateWindow(), this function expects to receive a LPCWSTR.
Anyway, how can I set Visual Studio 2005 to compile the way Visual C++ 6.0 did it (or how can I make these character interpretation problem to be solved)?
Thank you.












