Click here to Skip to main content
16,016,425 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dr Watson dump :-\ Pin
pete mcquain18-Feb-03 6:34
pete mcquain18-Feb-03 6:34 
GeneralRe: Dr Watson dump :-\ Pin
will138318-Feb-03 7:32
will138318-Feb-03 7:32 
GeneralI'm This Far Now Pin
will138318-Feb-03 7:48
will138318-Feb-03 7:48 
GeneralRe: I'm This Far Now Pin
AlexO18-Feb-03 8:00
AlexO18-Feb-03 8:00 
GeneralRe: I'm This Far Now Pin
will138318-Feb-03 8:04
will138318-Feb-03 8:04 
GeneralRe: I'm This Far Now Pin
AlexO18-Feb-03 8:13
AlexO18-Feb-03 8:13 
GeneralRe: I'm This Far Now Pin
will138318-Feb-03 8:33
will138318-Feb-03 8:33 
GeneralRe: I'm This Far Now Pin
Alvaro Mendez18-Feb-03 8:50
Alvaro Mendez18-Feb-03 8:50 
I think AlexO hit the nail in the head.

According to the docs for LVITEM, pszText is an LPTSTR, which means that it's just a pointer. It's not a character buffer, like your program is treating it. When you copy onto it, you're overwriting whatever memory it's pointing to at the moment, which may be harmless in some cases but not in others. Dead | X|

I'm not sure what your function is used for, but it looks like its intent is to change the text of the list view items. I don't understand why you're doing it this way instead of using SetItemText but whatever.

At any rate, the quick solution to this problem is to stop copying into the pointer and just assign it to a buffer that does not go away. The easiest way to do that is to make your string declaration static:

static CString string;

Then instead of ::lstrcpy (pDispInfo->item.pszText, string), you can do something like this:

pDispInfo->item.pszText = (LPTSTR)(LPCTSTR)string;

This will point it to the string's buffer, which will not go away since it will be static.

That's the quick and dirty solution, without knowing much else.

Regards,
Alvaro


All you need in this life is ignorance and confidence, and then success is sure. -- Mark Twain
GeneralRe: I'm This Far Now Pin
AlexO18-Feb-03 9:02
AlexO18-Feb-03 9:02 
GeneralRe: I'm This Far Now Pin
Alvaro Mendez18-Feb-03 9:36
Alvaro Mendez18-Feb-03 9:36 
GeneralRe: I'm This Far Now Pin
will138318-Feb-03 9:48
will138318-Feb-03 9:48 
GeneralRe: I'm This Far Now Pin
AlexO18-Feb-03 9:59
AlexO18-Feb-03 9:59 
GeneralRe: I'm This Far Now Pin
will138318-Feb-03 10:05
will138318-Feb-03 10:05 
GeneralRe: I'm This Far Now Pin
will138318-Feb-03 10:08
will138318-Feb-03 10:08 
GeneralTemp directory Pin
-Dy18-Feb-03 2:07
-Dy18-Feb-03 2:07 
GeneralRe: Temp directory Pin
Hans Ruck18-Feb-03 2:42
Hans Ruck18-Feb-03 2:42 
GeneralRe: Temp directory Pin
HENDRIK R18-Feb-03 3:37
HENDRIK R18-Feb-03 3:37 
GeneralRe: Temp directory Pin
-Dy18-Feb-03 4:04
-Dy18-Feb-03 4:04 
GeneralRe: Temp directory Pin
Joel Lucsy18-Feb-03 4:17
Joel Lucsy18-Feb-03 4:17 
GeneralQuestion about __FUNCTION__ precompile directive. Pin
George218-Feb-03 2:01
George218-Feb-03 2:01 
GeneralRe: Question about __FUNCTION__ precompile directive. Pin
AlexO18-Feb-03 2:49
AlexO18-Feb-03 2:49 
GeneralRe: Question about __FUNCTION__ precompile directive. Pin
George218-Feb-03 2:53
George218-Feb-03 2:53 
GeneralRe: Question about __FUNCTION__ precompile directive. Pin
AlexO18-Feb-03 3:25
AlexO18-Feb-03 3:25 
GeneralRe: Question about __FUNCTION__ precompile directive. Pin
George218-Feb-03 14:53
George218-Feb-03 14:53 
GeneralProblem with Certificates ....cryptography ...plz help Pin
Dimitri Denamany17-Feb-03 23:51
sussDimitri Denamany17-Feb-03 23:51 

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.