Casting to/from STL types to MFC types 
Author Message
 Casting to/from STL types to MFC types

I'm trying to encapsulate the MFC UI toolkit on embedded Visual C++
inside standard (ie, portable) C++ code (STL, etc.).  One of the major
stumbling blocks is trying to convert standard C++ strings to MFC
strings (ie, string to CString) and back the other way around (CString
to string).

Does anyone have some sample code snipnets that will get me on my way?

I'm using the for PocketPC for x86, ARM, and MIPS.

Thanks in advance.



Mon, 16 Feb 2004 01:57:34 GMT  
 Casting to/from STL types to MFC types
Hi
I've used the following STL type with CString.
basic_string<wchar_t>
It will give you a wide version of the standard string.
I guess it is possible to typedef it into something less ugly for your
project.

Lars Hansen


Quote:
> I'm trying to encapsulate the MFC UI toolkit on embedded Visual C++
> inside standard (ie, portable) C++ code (STL, etc.).  One of the major
> stumbling blocks is trying to convert standard C++ strings to MFC
> strings (ie, string to CString) and back the other way around (CString
> to string).

> Does anyone have some sample code snipnets that will get me on my way?

> I'm using the for PocketPC for x86, ARM, and MIPS.

> Thanks in advance.



Sat, 13 Mar 2004 20:09:57 GMT  
 Casting to/from STL types to MFC types
I use wstring (it's a typedefed basic_string<wchar_t>) as in this example:

std::wstring s;
CString c;

s = (LPCTSTR)c;     //CString to wstring copy
c = s.c_str();             //wstring to CString copy

Giuseppe Govi


Quote:
> Hi
> I've used the following STL type with CString.
> basic_string<wchar_t>
> It will give you a wide version of the standard string.
> I guess it is possible to typedef it into something less ugly for your
> project.

> Lars Hansen



> > I'm trying to encapsulate the MFC UI toolkit on embedded Visual C++
> > inside standard (ie, portable) C++ code (STL, etc.).  One of the major
> > stumbling blocks is trying to convert standard C++ strings to MFC
> > strings (ie, string to CString) and back the other way around (CString
> > to string).

> > Does anyone have some sample code snipnets that will get me on my way?

> > I'm using the for PocketPC for x86, ARM, and MIPS.

> > Thanks in advance.



Mon, 15 Mar 2004 04:57:37 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Type Casting between Base and Derived Type (Serialization of objects with Type members)

2. type casting to / from pointers to incomplete data types

3. type casting to / from pointers to incomplete data types

4. cast cstring type to integer type

5. Why can't overload type cast to base type (object)

6. type-cast of MFC

7. type-cast of MFC

8. Variables and types of type "Type"

9. Cast to a dynamic type?

10. Dynamically Type Casting Array[]

11. cast back to orginal type

12. Casting a object instance to a unknown type.

 

 
Powered by phpBB® Forum Software