is there any efficient way to insert a string into an edit control without simulating the key presses through messages like WM_KEYDOWN? i mean, insert a string wherever the cursor is, even if its in the middle of a document?
is there any efficient way to insert a string into an edit control without simulating the key presses through messages like WM_KEYDOWN? i mean, insert a string wherever the cursor is, even if its in the middle of a document?
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials
SendMessage(hwnd, WM_SETTEXT, 0, (long)actText);
If there is no text selected, you can send an EM_REPLACESEL message. If nothing is selected, the default action is to insert the text at the cursor position. You could use EM_SETSEL to set a zero length select range at the cursor position if you want to be sure nothing else is selected.
*** EDIT ***
>>> SendMessage(hwnd, WM_SETTEXT, 0, (long)actText);
That won't work, that would replace the existing text, not insert after the cursor. You could use GetWindowText() to get the current text into a buffer then modify the buffer to your liking and send it back with SetWindowText() if you wanted to.
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.
cheers adrian. thanks anyway for trying knutso. the best way to learn is to make mistakes.
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials
Oops! I should look more carefully at who the poster is before answering, hell, it was early in the day and I just read the question, sorry Ben!
Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.