CEdit problem in displaying CR and LF [modified]
-
Dear All, I am using CEdit to display a text in an array like below :
wchar_t szData[5];
szData[0] = 'a';
szData[1] = 'b';
szData[2] = 'c';
szData[3] = '\r';
szData[4] = '\0';
m_EDIT.ReplaceSel(szData);//even I tried with SetWindowTextWBut, when I display the contents, the CR is displaying as boxes, even I tried with '\n' and the result is the same. Since, it is displaying as a box, further text is not displayed on the next line and it is printed in the same line with boxes after every "abc". Please help to solve the issue.
modified on Tuesday, August 25, 2009 5:15 AM
-
Dear All, I am using CEdit to display a text in an array like below :
wchar_t szData[5];
szData[0] = 'a';
szData[1] = 'b';
szData[2] = 'c';
szData[3] = '\r';
szData[4] = '\0';
m_EDIT.ReplaceSel(szData);//even I tried with SetWindowTextWBut, when I display the contents, the CR is displaying as boxes, even I tried with '\n' and the result is the same. Since, it is displaying as a box, further text is not displayed on the next line and it is printed in the same line with boxes after every "abc". Please help to solve the issue.
modified on Tuesday, August 25, 2009 5:15 AM
First, there's an error in your code: you are not increasing the index. Is it only a typpo ? Second, you need to have both the carriage return and newline characters (I don't remember in which order, you'll need to test it).
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
First, there's an error in your code: you are not increasing the index. Is it only a typpo ? Second, you need to have both the carriage return and newline characters (I don't remember in which order, you'll need to test it).
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++I am really sorry Cedric Moonen. It is a typing mistake in my previous message (now corrected it).
Cedric Moonen wrote:
Second, you need to have both the carriage return and newline characters
I agree with your comment, when I use \r\n then it is displaying in the nextline but my real problem is that my input text will come like the following :
"abc\rxyz\rpqr\r"
-
I am really sorry Cedric Moonen. It is a typing mistake in my previous message (now corrected it).
Cedric Moonen wrote:
Second, you need to have both the carriage return and newline characters
I agree with your comment, when I use \r\n then it is displaying in the nextline but my real problem is that my input text will come like the following :
"abc\rxyz\rpqr\r"
Then you will need to convert it so that all the \r sequences are replaced by \r\n sequences. std::string and CString have functions to do that.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
Dear All, I am using CEdit to display a text in an array like below :
wchar_t szData[5];
szData[0] = 'a';
szData[1] = 'b';
szData[2] = 'c';
szData[3] = '\r';
szData[4] = '\0';
m_EDIT.ReplaceSel(szData);//even I tried with SetWindowTextWBut, when I display the contents, the CR is displaying as boxes, even I tried with '\n' and the result is the same. Since, it is displaying as a box, further text is not displayed on the next line and it is printed in the same line with boxes after every "abc". Please help to solve the issue.
modified on Tuesday, August 25, 2009 5:15 AM
bhanu_8509 wrote:
wchar_t szData[5]; szData[0] = 'a'; szData[1] = 'b'; szData[2] = 'c'; szData[3] = '\r'; szData[4] = '\0';
I don't see the purpose behind populating each and every element in a string separately. May be you haven't known of functions like
strcpy
? This would work for both Unicode and MBCS builds:TCHAR szData[4];
_tcscpy(szData, _T("abc"));
m_EDIT.SetWindowText(szData);For entering a new line, use
\r\n
and make sure that in the properties of the edit box, "multiline" is set to true.It is a crappy thing, but it's life -^ Carlo Pallini
modified on Tuesday, August 25, 2009 6:44 AM
-
bhanu_8509 wrote:
wchar_t szData[5]; szData[0] = 'a'; szData[1] = 'b'; szData[2] = 'c'; szData[3] = '\r'; szData[4] = '\0';
I don't see the purpose behind populating each and every element in a string separately. May be you haven't known of functions like
strcpy
? This would work for both Unicode and MBCS builds:TCHAR szData[4];
_tcscpy(szData, _T("abc"));
m_EDIT.SetWindowText(szData);For entering a new line, use
\r\n
and make sure that in the properties of the edit box, "multiline" is set to true.It is a crappy thing, but it's life -^ Carlo Pallini
modified on Tuesday, August 25, 2009 6:44 AM
You're were out-of-bounds again! ;P :laugh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
You're were out-of-bounds again! ;P :laugh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]OK OK... :)
It is a crappy thing, but it's life -^ Carlo Pallini
-
OK OK... :)
It is a crappy thing, but it's life -^ Carlo Pallini
OK OK... :) :laugh:
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Then you will need to convert it so that all the \r sequences are replaced by \r\n sequences. std::string and CString have functions to do that.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++Dear Cedric, Thank you so much now I solved the proble but only one thing is pending. For instance, if the text has more no. of \r in it then how could I replace all the \r. Please give me your advice. I have done already for one occurance of \r and the code is below.
char *str = "abc\rxyz";
stdstr = str;
int idx = stdstr.find('\r');
stdstr.insert((idx+1),1,'\n');
const char* rcData = stdstr.c_str();
int lenA = lstrlenA(rcData);
int lenW;
wchar_t *unircData;
lenW = ::MultiByteToWideChar(CP_ACP,0,rcData,lenA,0,0);
unircData = SysAllocStringLen(0,lenW);
if(lenW >0)
{
::MultiByteToWideChar(CP_ACP,0,rcData,lenA,unircData,lenW);
}
unircData[lenW] = 0;
m_EDIT.ReplaceSel(unircData);