Click here to Skip to main content
15,889,176 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: can not find MSVCR80D.dll? Pin
Hamid_RT12-Apr-08 5:25
Hamid_RT12-Apr-08 5:25 
GeneralRe: can not find MSVCR80D.dll? Pin
George_George12-Apr-08 20:16
George_George12-Apr-08 20:16 
GeneralRe: can not find MSVCR80D.dll? Pin
Hamid_RT12-Apr-08 23:49
Hamid_RT12-Apr-08 23:49 
QuestionA question on memory allocation... Pin
KellyR27-Nov-07 14:27
KellyR27-Nov-07 14:27 
AnswerRe: A question on memory allocation... Pin
Llasus27-Nov-07 14:52
Llasus27-Nov-07 14:52 
QuestionRe: A question on memory allocation... Pin
KellyR27-Nov-07 15:03
KellyR27-Nov-07 15:03 
AnswerRe: A question on memory allocation... Pin
Mark Salsbery27-Nov-07 15:30
Mark Salsbery27-Nov-07 15:30 
GeneralRe: A question on memory allocation... Pin
KellyR28-Nov-07 3:31
KellyR28-Nov-07 3:31 
Unfortunately it's not that simple, the string type is a CStringW yes but the characters are actually in CStringA format so the conversion is necessary. The compiler doesn't realize that it's a CStringA because the project settings for my front-end project define _UNICODE but my backend (a series of separate projects and libraries) is all in MBCS, which is where the function comes from (i.e. lots of text without the _T macro). I can't change that - the backend is going to return a multi-byte CString no matter what I do, but the program and compiler think it's of type CStringW because of my front-end project settings.

sprintf works correctly because of the above reason (even though CString type is a wide character array, the data inside is actually MBCS format).

I need the BSTR because MultiByteToWideChar will not compile if I define the type as wchar_t, and SetWindowText would require a conversion if I defined the type as LPWSTR. If I use BSTR I can do what I did and it works, if I don't use a BSTR additional steps are required.

I have tried:
CStringA strText = (CStringA)function();
CString strTextGeneric(strText);    
m_EditControl.SetWindowText(strTextGeneric);

But that does not work, it just returns some garbled crud, probably because it thinks that the piece of code that returns CStringA is actually a CStringW.

But you're right about the +1 for null terminator, I did forget about that. However it doesn't help if I add that, it still crashes unless I define convertThis as a char array with a static length.

KR

GeneralRe: A question on memory allocation... Pin
Mark Salsbery28-Nov-07 5:16
Mark Salsbery28-Nov-07 5:16 
GeneralRe: A question on memory allocation... Pin
KellyR28-Nov-07 5:36
KellyR28-Nov-07 5:36 
GeneralRe: A question on memory allocation... Pin
Mark Salsbery28-Nov-07 5:39
Mark Salsbery28-Nov-07 5:39 
QuestionRe: A question on memory allocation... Pin
David Crow27-Nov-07 15:41
David Crow27-Nov-07 15:41 
AnswerRe: A question on memory allocation... Pin
Stephen Hewitt27-Nov-07 16:32
Stephen Hewitt27-Nov-07 16:32 
GeneralRe: A question on memory allocation... Pin
KellyR28-Nov-07 3:44
KellyR28-Nov-07 3:44 
AnswerRe: A question on memory allocation... Pin
Michael Dunn27-Nov-07 16:37
sitebuilderMichael Dunn27-Nov-07 16:37 
QuestionQuestion on passing data to from threads Pin
Rhymhoont27-Nov-07 10:37
Rhymhoont27-Nov-07 10:37 
AnswerRe: Question on passing data to from threads Pin
JudyL_MD27-Nov-07 10:48
JudyL_MD27-Nov-07 10:48 
GeneralRe: Question on passing data to from threads Pin
Rhymhoont27-Nov-07 11:47
Rhymhoont27-Nov-07 11:47 
AnswerRe: Question on passing data to from threads Pin
David Crow28-Nov-07 2:57
David Crow28-Nov-07 2:57 
GeneralRe: Question on passing data to from threads Pin
JudyL_MD28-Nov-07 6:42
JudyL_MD28-Nov-07 6:42 
QuestionDrop down list behaviour in comboboxes Pin
Wxffles27-Nov-07 9:21
Wxffles27-Nov-07 9:21 
QuestionRe: Drop down list behaviour in comboboxes Pin
David Crow27-Nov-07 10:03
David Crow27-Nov-07 10:03 
QuestionRe: Drop down list behaviour in comboboxes [modified] Pin
Wxffles27-Nov-07 11:46
Wxffles27-Nov-07 11:46 
AnswerRe: Drop down list behaviour in comboboxes Pin
led mike27-Nov-07 10:08
led mike27-Nov-07 10:08 
QuestionMenu Item not being enabled?? Pin
Kiran Satish27-Nov-07 8:14
Kiran Satish27-Nov-07 8:14 

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.