problem with add old string to new string in edit box (MFC)

T

Tio

my code:


if (new data )
{

CString* pStr = (CString*)wParam; //data come with some
com port (PostMessage)
CString p2Str; //old string in edit box
m_dataa.GetWindowText(p2Str);

*pStr= p2Str+*pStr; // add old string to new string

m_dataa.SetWindowText(*pStr); // send new string to edit box
delete pStr;

}

in first step I have in edit box "12345"
then come new data "6789"
so it should be after adding two string "12345 6789" in edit box but
is "12345 89"
why I lost two signs?
 
V

Victor Bazarov

Tio said:
my code:


if (new data )
{

CString* pStr = (CString*)wParam; //data come with some
com port (PostMessage)
CString p2Str; //old string in edit box
m_dataa.GetWindowText(p2Str);

*pStr= p2Str+*pStr; // add old string to new string

m_dataa.SetWindowText(*pStr); // send new string to edit box
delete pStr;

}

in first step I have in edit box "12345"
then come new data "6789"
so it should be after adding two string "12345 6789" in edit box but
is "12345 89"
why I lost two signs?

First of all, nothing in your code suggests you're adding a space between
your strings. Perhaps the operator+ for 'CString' does that, I don't know
since CString is not a standard class. Perhaps you're not telling us all
like it is in reality (like 'p2Str' actually contains a space after "5" or
that new data has a space in front of it).

Second, whatever you do that causes this malfunction, is most likely not
in this code, but rather outside, in the code you didn't post.

Third, your program's functionality depends on MFC (apparently), and this
is not the right place to discuss MFC issues. Try
'microsoft.public.vc.mfc'.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top