From: Derek on
CString sHexBgColor;

string Str = (LPCTSTR)m_sHexBgColor;

The plan is to use it with this method:

ConvertColor(string color);



"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
news:1140027010.407000.103470(a)g43g2000cwa.googlegroups.com...
> Can you show the code which is causing this error?
>
> ---------
> Ajay Kalra
> ajaykalra(a)yahoo.com
>


From: Derek on
David, sorry I miss your reply.
Your solution works!

typedef std::basic_string<TCHAR> tstring;
CString Temp = _T("This is a test");
tstring Str = (LPCTSTR)Temp;

Thanks a lot!



"David Wilkinson" <no-reply(a)effisols.com> wrote in message
news:uRvzsJlMGHA.3728(a)tk2msftngp13.phx.gbl...
> Tom Serface wrote:
>
>> Hi Tim,
>>
>> It depends on the compile options you are using. LPCTSTR is safer
>> because it will morph to be MBCS or Unicode depending on how the program
>> is compiled.
>>
>> Tom
>>
>> "Tim Ward" <tw2(a)ipaccess.com> wrote in message
>> news:45h2bgF6p7ofU1(a)individual.net...
>>
>>>"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
>>>news:1140017418.811732.197740(a)g14g2000cwa.googlegroups.com...
>>>
>>>>What exactly is the problem? All you are using is the operator LPCTSTR
>>>>of CString. Show the code that is not working.
>>>
>>>Yes, I'd expect that to work better than the
>>>
>>>
>>>>string Str = (LPCSTR)Temp;
>>>
>>>in the original answer.
>>>
>>>--
>>>Tim Ward
>>>Brett Ward Limited - www.brettward.co.uk
>>>
>>>
>
> Tom:
>
> Yes, but you cannot convert Unicode string to std::string. To get
> ANSI-UNICODE compatibility you need to do something like
>
> typedef std::basic_string<TCHAR> tstring;
>
> CString Temp = _T("This is a test");
> tstring Str = (LPCTSTR)Temp;
>
> David Wilkinson


From: Ajay Kalra on
This will not work for UNICODE as expected. As pointed out earlier, you
should not be using string, use tstring/wstring instead.

--------
Ajay Kalra
ajaykalra(a)yahoo.com

From: Derek on
Yes, I noticed that. I compile now, but at runtime getting:
C++ exception: std::out_of_range @ 0x0013c7d8.
thanks

"Ajay Kalra" <ajaykalra(a)yahoo.com> wrote in message
news:1140028161.735387.273220(a)g44g2000cwa.googlegroups.com...
> This will not work for UNICODE as expected. As pointed out earlier, you
> should not be using string, use tstring/wstring instead.
>
> --------
> Ajay Kalra
> ajaykalra(a)yahoo.com
>


From: Ajay Kalra on
What line of code is doing this?

--------
Ajay Kalra
ajaykalra(a)yahoo.com