Click here to Skip to main content
16,004,944 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Migration java -> c++ Pin
Zizilamoroso16-Apr-02 7:00
Zizilamoroso16-Apr-02 7:00 
GeneralRe: Migration java -> c++ Pin
Ravi Bhavnani16-Apr-02 6:28
professionalRavi Bhavnani16-Apr-02 6:28 
GeneralISAPI filter for raw data Pin
rajacm16-Apr-02 5:41
rajacm16-Apr-02 5:41 
GeneralOFNHookProc Pin
Anthony988716-Apr-02 5:35
Anthony988716-Apr-02 5:35 
GeneralBest collection class for CPoint object. Pin
kursatkaraca16-Apr-02 5:28
kursatkaraca16-Apr-02 5:28 
GeneralUNICODE Pin
Rage16-Apr-02 5:23
professionalRage16-Apr-02 5:23 
GeneralRe: UNICODE Pin
Philip Patrick16-Apr-02 6:35
professionalPhilip Patrick16-Apr-02 6:35 
GeneralRe: UNICODE Pin
Le centriste16-Apr-02 6:52
Le centriste16-Apr-02 6:52 
1- ATL (and I think also MFC) comes with a bunch of macros:

An excerpt from MSDN library:

ATL 3.0 String Conversion Macros



The original text conversion macros are still available and are listed in the table below:



ATL 3.0 String Conversion Macros



A2BSTR OLE2A T2A W2A
A2COLE OLE2BSTR T2BSTR W2BSTR
A2CT OLE2CA T2CA W2CA
A2CW OLE2CT T2COLE W2COLE
A2OLE OLE2CW T2CW W2CT
A2T OLE2T T2OLE W2OLE
A2W OLE2W T2W W2T

All those macros map Ascii (A), OLE (OLE), and Wide (W) strings to another type.

Ex.

USES_CONVERSION;
_TCHAR *tsz = _T("hello world");
WCHAR *wsz = T2W(tsz);
LPOLESTR *olesz = W2OLE(wsz);
char *sz = OLE2A(olesz);
BSTR bsz = A2BSTR(sz);


Don't forget the USES_CONVERSION macro. You don't need to free memory, except for the X2BSTR ones, which require a call to SysFreeString function.

2-

_wtoi (and _ttoi for the _TCHAR ones).

Michel

If I am wrong or said something stupid, I apologize in advance Wink | ;)
GeneralRe: UNICODE Pin
Le centriste16-Apr-02 18:25
Le centriste16-Apr-02 18:25 
GeneralStartPage() and Document/View Pin
dazinith16-Apr-02 5:19
dazinith16-Apr-02 5:19 
GeneralRe: StartPage() and Document/View Pin
Roger Allen16-Apr-02 6:34
Roger Allen16-Apr-02 6:34 
GeneralRe: StartPage() and Document/View Pin
Roger Allen16-Apr-02 6:40
Roger Allen16-Apr-02 6:40 
GeneralRe: StartPage() and Document/View Pin
Jonathan Craig16-Apr-02 7:28
Jonathan Craig16-Apr-02 7:28 
QuestionFile equivalent to ntprint.inf in Win98 ? Pin
Somu Lakshmanan16-Apr-02 5:18
Somu Lakshmanan16-Apr-02 5:18 
GeneralAccessing text controls of other dialog box Pin
16-Apr-02 4:58
suss16-Apr-02 4:58 
GeneralRe: Accessing text controls of other dialog box Pin
Chris Losinger16-Apr-02 5:05
professionalChris Losinger16-Apr-02 5:05 
GeneralRe: Accessing text controls of other dialog box Pin
18-Apr-02 4:56
suss18-Apr-02 4:56 
GeneralRe: Accessing text controls of other dialog box Pin
dazinith16-Apr-02 5:34
dazinith16-Apr-02 5:34 
GeneralRe: Accessing text controls of other dialog box Pin
18-Apr-02 4:55
suss18-Apr-02 4:55 
QuestionHow can I easily access addresses in DirectPlay? Pin
Vinsent16-Apr-02 4:48
Vinsent16-Apr-02 4:48 
GeneralProblem with CWnd::PreSubclassWindow Pin
Joel Holdsworth16-Apr-02 3:45
Joel Holdsworth16-Apr-02 3:45 
GeneralRe: Problem with CWnd::PreSubclassWindow Pin
Joaquín M López Muñoz16-Apr-02 9:55
Joaquín M López Muñoz16-Apr-02 9:55 
GeneralRe: Problem with CWnd::PreSubclassWindow Pin
Joel Holdsworth18-Apr-02 7:48
Joel Holdsworth18-Apr-02 7:48 
GeneralRe: Problem with CWnd::PreSubclassWindow Pin
Joaquín M López Muñoz18-Apr-02 8:16
Joaquín M López Muñoz18-Apr-02 8:16 
GeneralRe: Problem with CWnd::PreSubclassWindow Pin
Joel Holdsworth19-Apr-02 10:53
Joel Holdsworth19-Apr-02 10:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.