Click here to Skip to main content
16,010,334 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to get a popup menu by right clicking? Pin
Tomasz Sowinski24-Jul-01 1:21
Tomasz Sowinski24-Jul-01 1:21 
GeneralProblem with strings Pin
24-Jul-01 0:47
suss24-Jul-01 0:47 
GeneralRe: Problem with strings Pin
Gerry24-Jul-01 1:09
Gerry24-Jul-01 1:09 
GeneralProblem with strings Pin
24-Jul-01 1:41
suss24-Jul-01 1:41 
GeneralRe: Problem with strings Pin
Tomasz Sowinski24-Jul-01 1:48
Tomasz Sowinski24-Jul-01 1:48 
GeneralProblem with strings Pin
24-Jul-01 3:50
suss24-Jul-01 3:50 
GeneralRe: Problem with strings Pin
Tomasz Sowinski24-Jul-01 4:12
Tomasz Sowinski24-Jul-01 4:12 
GeneralRe: Problem with strings Pin
24-Jul-01 4:45
suss24-Jul-01 4:45 
BSTR is defined as wchar_t * and thus is really a pointer. You should also uses _bstr_t type for your class member as that class is a wrapper for BSTR and will handle copy and similar things properly.

The reason why the string would be reused is that the pointer (stringA member) is initialized (incorrectly) from an implicit conversion operator of class _bstr_t. Since _bstr_t("SomethingA") create a temporary object which will last only for the expression, the memory allocated by the (temporary) object will freed before the next instruction and will be available for subsequent allocation.

So Windows may reuse the same address for that subsequent allocation and this is why the first string (stringA member) may now have that value. In any case, as mentionned in another answer, stringA member is not properly initilized...

If you want to uses BSTR for the class member, then it should be initilized using SysAllocString and it should then be freed by the class destructor using SysFreeString.

Philippe
GeneralRe: Problem with strings Pin
24-Jul-01 5:03
suss24-Jul-01 5:03 
Generaltake ownership Pin
24-Jul-01 0:43
suss24-Jul-01 0:43 
GeneralChanging title bar in SDI mode ... Pin
Hadi Rezaee24-Jul-01 0:18
Hadi Rezaee24-Jul-01 0:18 
GeneralRe: Changing title bar in SDI mode ... Pin
Tomasz Sowinski24-Jul-01 1:24
Tomasz Sowinski24-Jul-01 1:24 
GeneralRe: Changing title bar in SDI mode ... Pin
Hadi Rezaee24-Jul-01 2:24
Hadi Rezaee24-Jul-01 2:24 
GeneralRe: Changing title bar in SDI mode ... Pin
Tomasz Sowinski24-Jul-01 2:34
Tomasz Sowinski24-Jul-01 2:34 
GeneralProblem with CWinApp::Run. Pin
24-Jul-01 0:13
suss24-Jul-01 0:13 
GeneralRe: Problem with CWinApp::Run. Pin
Tomasz Sowinski24-Jul-01 1:07
Tomasz Sowinski24-Jul-01 1:07 
GeneralRe: Problem with CWinApp::Run. Pin
24-Jul-01 2:46
suss24-Jul-01 2:46 
GeneralRe: Problem with CWinApp::Run. Pin
Tomasz Sowinski24-Jul-01 2:54
Tomasz Sowinski24-Jul-01 2:54 
GeneralRe: Problem with CWinApp::Run. Pin
24-Jul-01 9:52
suss24-Jul-01 9:52 
Questionmcisendcommand() & sampling rate? Pin
zecodela23-Jul-01 23:25
zecodela23-Jul-01 23:25 
QuestionTHIS ? Pin
Gérald Mercet23-Jul-01 22:38
Gérald Mercet23-Jul-01 22:38 
AnswerRe: THIS ? Pin
Christian Graus23-Jul-01 23:01
protectorChristian Graus23-Jul-01 23:01 
GeneralRe: THIS ? Pin
Gerry23-Jul-01 23:03
Gerry23-Jul-01 23:03 
GeneralRe: THIS ? Pin
Christian Graus23-Jul-01 23:06
protectorChristian Graus23-Jul-01 23:06 
GeneralRe: THIS ? Pin
Gerry23-Jul-01 23:58
Gerry23-Jul-01 23:58 

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.