Answer the question
In order to leave comments, you need to log in
How to properly update an EDITTEXT element?
I'm writing a program that uses hooks to display basic mouse events. To display, I use a dialog box with a resource-defined text field
(EDITTEXT IDC_EDIT_REC, 7, 7, 160, 105, ES_MULTILINE|ES_WANTRETURN|WS_BORDER|ES_AUTOVSCROLL|ES_READONLY)
Every time the program receives a new event message, I read the contents of the text field and I append to it using strcat string. The problem is that in this case wrapping to a new line does not work ('\n' is ignored, where do not shove it) and autoscrolling when the field overflows vertically. What is the correct way to update the text field in this case?
Answer the question
In order to leave comments, you need to log in
1. Use character 13 (\r) to break lines.
2. ES_AUTOVSCROLL Automatically scrolls text up one page when the user presses the ENTER key on the last line.
So that's not what you need, you just need to put the cursor at the end (Delphi sources give the message EM_SETSEL).
3. I don't know how you manage memory, but be extremely careful with this.
4. strcat will be slow when there is a lot of data, consider simulating input (EM_REPLACESEL message).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question