Dear all,
I have a little problem with an edit control.
I'd like to add text and add lines. "Add" means appending text to the text already in there.
Adding text: This can be done using EM_Replacesel, and making sure the selection corresponds to nothing but the end of the text that's already in there.
It works in principle by this function:
int Edit_AddText(HWND hEdit, char* txt)
{
//deselect everything furst
SendMessage(hEdit,
(UINT) EM_SETSEL,
(WPARAM) -1,
(LPARAM) 0);
SendMessage(hEdit,
(UINT) EM_REPLACESEL,
(WPARAM) FALSE,
(LPARAM) txt);
}
So if I want to add a line, rather than just text, I thought this should work:
int Edit_AddLine(HWND hEdit, char* txt)
{
char* Newline = "\n"; // or "\n\r" or "\r" etc
Edit_AddText(hEdit, txt);
Edit_AddText(hEdit, Newline);
}
But it does NOT work correctly. The "\n" (or any combi of "\n" and/or "\r" gives a weirdo character in the edit. That's annoying. I also tried forcing ascii(13) and/or ascii(10) into the strings with code, but the result is the same :cry: . The Edit simply seems resistant to such characters.
How do I get around it?
Many thanks for your help.
Yates