views:

375

answers:

2

I was using

CreateEx(

0, className, "XXX", WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, parent, 0); in Visual C++ 6.0.

when i port the same to VS 2008.., its giving an error message saying that..

error C2664: 'BOOL CWnd::CreateEx(DWORD,LPCTSTR,LPCTSTR,DWORD,const RECT &,CWnd *,UINT,LPVOID)' : cannot convert parameter 3 from 'const char [7]' to 'LPCTSTR'

how to rectify the same thanks Chitra

+2  A: 

LPCTSTR is a typedef pointing the wide-char variant, if that's enabled (it is by default, in new versions). Just change your literals to wide-char (or better yet, use the appropriate macro to return the correct literal):

CreateEx(0, className, _T("XXX"),
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, rect, parent, 0);
Konrad Rudolph
This is almost correct, but not quite. L"XXX" specifies a wide character string. For LPCTSTR, which allows compatibility with both ANSI and Unicode you need _T("XXX"). http://msdn.microsoft.com/en-us/library/c426s321.aspx
ChrisN
@Chris: thanks, forgot about that one.
Konrad Rudolph
+1  A: 

To directly port your old code you can turn off Unicode by right clicking on your project name, going to properties, and then changing the character set to "multibyte".

Assuming of course that your original code didn't already use Unicode...

Matthew Iselin