Quote: error C2440: 'initializing' : cannot convert from 'const char [7]' to 'LPCTSTR' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style casti can't work out why its doing this. Im using the visual c++ 2005 beta 2 edition, under 'console application' because for some reason i can't select win32 app in the project creation window, which might be causing this problem? thanks
Whats wrong with this LPCTSTR name = "Runner"? possible visual c++ 2005b2 problem?
hi in my c++ program ive got:
#define WIN32_MEAN_AND_LEAN
#include <windows.h>
#define CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include <string>
#include <sstream>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
LPCTSTR name = "Runner";
and im getting the error:
Quote:Original post by johnnyBravo
i can't work out why its doing this. Im using the visual c++ 2005 beta 2 edition, under 'console application' because for some reason i can't select win32 app in the project creation window, which might be causing this problem?
Take a look at my post here and a few above to see why. If you are not using the express edition, you should be able to make a Win32 app - you make a console app project, but then choose the 'Application Settings' option on that final screen before the project is made and choose Win32. Given that, you should have the platform SDK downloaded and installed as well.
As for the code, I think you have to do something like:
LPCTSTR name = _T("Runner"); or something like that to assign a literal to a pointer. This is probabally because either LPCSTR was redefined in the new SDK, or something like that. Also try a LPCTSTR name = reinterpret_cast<LPCTSTR>("Runner") as well. Good luck!
[edit]Or what AP said [smile]
_T("Runner"); didnt work, while the others did, the caption for my window looks like a solid white rectangle tho.
Ok I fixed the win32 app thanks to your post, but its kinda weird. In projects I made from beta 1, they work fine, eg i can just use:
wc.lpszClassName = "Runner";
or:
HWND hwnd = CreateWindow(wc.lpszClassName, "The caption",...
and these work fine.
its when I try the same thing in beta 2 created project, i ge the error i posted above. any ideas on what happening here?
Thanks
Ok I fixed the win32 app thanks to your post, but its kinda weird. In projects I made from beta 1, they work fine, eg i can just use:
wc.lpszClassName = "Runner";
or:
HWND hwnd = CreateWindow(wc.lpszClassName, "The caption",...
and these work fine.
its when I try the same thing in beta 2 created project, i ge the error i posted above. any ideas on what happening here?
Thanks
Welcome to the cluster-f*** that is #define _UNICODE.
It's #define WIN32_LEAN_AND_MEAN
Quote:#define WIN32_MEAN_AND_LEAN
It's #define WIN32_LEAN_AND_MEAN
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement