Click here to Skip to main content
16,008,075 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: visual C++.Net == Visual C++ 7.0 ? Pin
Matt Newman17-Dec-01 10:35
Matt Newman17-Dec-01 10:35 
GeneralRe: visual C++.Net == Visual C++ 7.0 ? Pin
Kuniva17-Dec-01 10:53
Kuniva17-Dec-01 10:53 
AnswerRe: visual C++.Net == Visual C++ 7.0 ? Pin
Nemanja Trifunovic17-Dec-01 10:52
Nemanja Trifunovic17-Dec-01 10:52 
QuestionCan I play MPEG in Video for Windows? Pin
JerzyPeter17-Dec-01 10:22
JerzyPeter17-Dec-01 10:22 
Generaltypecasting CString to LPSTR Pin
Dave K Dosanjh17-Dec-01 10:02
Dave K Dosanjh17-Dec-01 10:02 
GeneralRe: typecasting CString to LPSTR Pin
Dave Goodman17-Dec-01 10:20
Dave Goodman17-Dec-01 10:20 
GeneralRe: typecasting CString to LPSTR Pin
Michael Dunn17-Dec-01 11:01
sitebuilderMichael Dunn17-Dec-01 11:01 
GeneralRe: typecasting CString to LPSTR Pin
Navin17-Dec-01 14:08
Navin17-Dec-01 14:08 
The way to do this really depends on what you are trying to do. It looks
like you are trying to put the contents of a CString into a structure. You
may be best off making a copy of the string, and then deleting it
when you are finished using your strucutre. E.g.,

lvitem.pszText = new TCHAR[File.GetFileName().GetLength()];
strcpy(lvitem.pszText, File.GetFileName());

...
delete [] lvitem.pszText;

This is probably the safest way to do it, although it does mean
you create more memory for the string.

If you need an LPTSTR for, say, one function call, you can
use GetBuffer() to get the LPTSTR, and then ReleaseBuffer() after
you're finished.

It can be unsafe to cast a CString like this:
(LPTSTR)(LPCTSTR)someString
.. becuase if the contents of the LPTSTR are changed,
you can run into all kinds of nastiness (believe me, I know from experience. Smile | :) )



The early bird may get the worm, but the second mouse gets the cheese.
GeneralAdd User Dialog Pin
Ed K17-Dec-01 9:49
Ed K17-Dec-01 9:49 
GeneralCurious Pin
17-Dec-01 9:07
suss17-Dec-01 9:07 
GeneralRe: Curious Pin
Joaquín M López Muñoz17-Dec-01 9:19
Joaquín M López Muñoz17-Dec-01 9:19 
GeneralRe: Curious Pin
17-Dec-01 9:22
suss17-Dec-01 9:22 
GeneralRe: Curious WHOOPS Pin
17-Dec-01 9:30
suss17-Dec-01 9:30 
GeneralRe: Curious WHOOPS Pin
Joaquín M López Muñoz17-Dec-01 9:45
Joaquín M López Muñoz17-Dec-01 9:45 
GeneralRe: Curious WHOOPS Pin
17-Dec-01 10:50
suss17-Dec-01 10:50 
GeneralRe: Curious WHOOPS Pin
Joaquín M López Muñoz17-Dec-01 11:04
Joaquín M López Muñoz17-Dec-01 11:04 
GeneralRe: Curious Thanks Pin
17-Dec-01 14:20
suss17-Dec-01 14:20 
GeneralSupport to Graph Pin
Tony Li17-Dec-01 8:30
Tony Li17-Dec-01 8:30 
GeneralRe: Support to Graph Pin
Joaquín M López Muñoz17-Dec-01 8:41
Joaquín M López Muñoz17-Dec-01 8:41 
GeneralSocket Communications - buffering problems Pin
Ted Christiansen17-Dec-01 7:58
Ted Christiansen17-Dec-01 7:58 
GeneralRe: Socket Communications - buffering problems Pin
Joaquín M López Muñoz17-Dec-01 9:05
Joaquín M López Muñoz17-Dec-01 9:05 
GeneralHatched Brushes + a Scrolling View = Wacky Lines Pin
D.D. de Kerf17-Dec-01 5:15
D.D. de Kerf17-Dec-01 5:15 
GeneralRe: Hatched Brushes + a Scrolling View = Wacky Lines Pin
Joaquín M López Muñoz17-Dec-01 5:29
Joaquín M López Muñoz17-Dec-01 5:29 
GeneralMAXIMIZE A DIALOG Pin
jafrazee17-Dec-01 4:42
jafrazee17-Dec-01 4:42 
GeneralRe: MAXIMIZE A DIALOG Pin
Ernest Laurentin17-Dec-01 5:14
Ernest Laurentin17-Dec-01 5: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.