CString?

Unimatrix_001
Unimatrix_001 used Ask the Experts™
on
Hi, I've got the following:

CString filetoload;
CString temporary;
GetWindowText(GetDlgItem(hWnd,EDT_NO2),filetoload.GetBuffer(300),299);
temporary = CString("myfile.txt");
filetoload = filetoload + temporary;
MessageBox(0,filetoload,"",0);

It refuses to add the contents of temporary on the end of filetoload...all it does is replace filetoload with temporary! Anybody please?

Thanks in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
CString filetoload;
CString temporary;
GetWindowText(GetDlgItem(hWnd,EDT_NO2),filetoload.GetBuffer(300),299);
temporary = CString("myfile.txt");
filetoload += temporary;
MessageBox(0,filetoload,"",0);
Replace :
filetoload = filetoload + temporary;
by :
filetoload += temporary;
Commented:
If you use the pointer returned by GetBuffer to change the string contents, you must call ReleaseBuffer before using any other CString member functions. So add the following line after the GetWindowText() call.

filetoload.ReleaseBuffer();

Author

Commented:
Thanks chensu worked a treat! ...guiguikun, there isn't a difference between what you put and what I had...Although I may stand to be corrected ;)
I thought CStrings were working like AinsiString (Borland C++), sorry :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial