Click here to Skip to main content
16,015,393 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How do i catch when the user selects an item in a listview control with the RIGHT mouse button? Pin
Tomasz Sowinski30-May-02 13:05
Tomasz Sowinski30-May-02 13:05 
GeneralRe: How do i catch when the user selects an item in a listview control with the RIGHT mouse button? Pin
redeemer30-May-02 13:28
redeemer30-May-02 13:28 
GeneralOveriding mouse events Pin
30-May-02 11:51
suss30-May-02 11:51 
GeneralVariable issues Pin
Stew30-May-02 11:37
Stew30-May-02 11:37 
GeneralRe: Variable issues Pin
Bill Wilson30-May-02 11:43
Bill Wilson30-May-02 11:43 
GeneralRe: Variable issues Pin
Stew30-May-02 12:01
Stew30-May-02 12:01 
GeneralRe: Variable issues Pin
Bill Wilson30-May-02 12:18
Bill Wilson30-May-02 12:18 
GeneralRe: Variable issues Pin
James R. Twine31-May-02 10:48
James R. Twine31-May-02 10:48 
   I think Bill Wilson nailed it for you: misunderstanding how CString works, and then abusing it like that usually leads to problems.  And whoever you saw using GetBuffer( 0 ) like that should be slapped! Smile | :)

   If you assign one CString to another, they will share the same memory.  When you instantiate a CString object, it automatically initializes itself to an empty string (which is why you should not initialize them with "": it just wastes time).  Internally, CStrings (this is different in VS.NET, BTW) keep an object around referred to by afxEmptyString, which is used to indicate an empty string.  Since you have two CStrings containing empty strings (thus both pointing to afxEmptyString), you can see that problems will occur is you then use CString::GetBuffer( 0 ) to get a buffer: you will "step on" (and likely over) the internal afxEmptyString object, and thus screwed every other empty CString out there!

   IMHO, I think that you would benefit from not misusing CString objects in the ways your code shows, and use normal char/TCHAR buffers.  For example, StrippedFileName and PlaybookFile could likely be plain buffers of MAX_PATH + 1 length, or even 32KB each, which your stack will likely have more than enough room for, and is long enough for a network-based path name.  You also avoid the unnecessary hit of dynamic memory allocation.

   IME, I have found misuse of CString objects to be pretty damn near, if not right at, the heart of MFC applications with performance problems (esp. after running for an extended period of time, and/or with multiple threads).

   Peace!

-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
(Try Check Favorites Sometime!)
GeneralCleaning up from Visual Studio 6 Pin
dazinith30-May-02 9:47
dazinith30-May-02 9:47 
GeneralRe: Cleaning up from Visual Studio 6 Pin
Ed Gadziemski30-May-02 11:06
professionalEd Gadziemski30-May-02 11:06 
GeneralRe: Cleaning up from Visual Studio 6 Pin
Jonathan Craig30-May-02 11:56
Jonathan Craig30-May-02 11:56 
GeneralRe: Cleaning up from Visual Studio 6 Pin
Tomasz Sowinski30-May-02 12:59
Tomasz Sowinski30-May-02 12:59 
GeneralRe: Cleaning up from Visual Studio 6 Pin
dazinith31-May-02 3:20
dazinith31-May-02 3:20 
GeneralRe: Cleaning up from Visual Studio 6 Pin
James R. Twine31-May-02 10:53
James R. Twine31-May-02 10:53 
GeneralRe: Cleaning up from Visual Studio 6 Pin
mocotrah31-Aug-02 3:01
mocotrah31-Aug-02 3:01 
QuestionHow to use Unicode to std::ostrstream Pin
JohnnyG30-May-02 9:26
JohnnyG30-May-02 9:26 
AnswerRe: How to use Unicode to std::ostrstream Pin
Rama Krishna Vavilala30-May-02 9:35
Rama Krishna Vavilala30-May-02 9:35 
GeneralRe: How to use Unicode to std::ostrstream Pin
JohnnyG30-May-02 10:58
JohnnyG30-May-02 10:58 
GeneralRe: How to use Unicode to std::ostrstream Pin
Rama Krishna Vavilala30-May-02 11:04
Rama Krishna Vavilala30-May-02 11:04 
GeneralRe: How to use Unicode to std::ostrstream Pin
JohnnyG31-May-02 3:44
JohnnyG31-May-02 3:44 
GeneralRe: How to use Unicode to std::ostrstream Pin
Rama Krishna Vavilala31-May-02 3:43
Rama Krishna Vavilala31-May-02 3:43 
GeneralRe: How to use Unicode to std::ostrstream Pin
JohnnyG31-May-02 3:54
JohnnyG31-May-02 3:54 
GeneralCurrent time Pin
esapp42030-May-02 8:49
esapp42030-May-02 8:49 
GeneralRe: Current time Pin
Ravi Bhavnani30-May-02 9:18
professionalRavi Bhavnani30-May-02 9:18 
GeneralRe: Current time Pin
Bill Wilson30-May-02 11:56
Bill Wilson30-May-02 11:56 

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.