Geeks With Blogs
Prabhu Kumar a tech twaddler..
Today I was developing a small utility application where I needed to append some text to a multiline edit control. When I ran through the list of Edit control messages, I could not find any that could be used to append text. WM_SETTEXT was overwriting the previous contents. And doing a WM_GETTEXT first, appending to it and then WM_SETTEXT seemed like an overkill.

A little bit of searching led me to EM_REPLACESEL message. This message is used to replace the currently selected text in the edit control with the specified text but there's a bit more to it. If there is no selected text in the edit control then the specified text is inserted at the current caret position. Since what I was using was a read-only edit control this works for me but I am not sure if it will work in all cases. I wonder if we need a SETCARETPOS message. So anyways, here's how to append text in an edit control:

HWND hWndEdit = GetDlgItem(g_hDlg, IDC_EDIT_BOX);

Posted on Wednesday, October 21, 2009 12:46 AM Applications | Back to top

Comments on this post: Applications: Appending text to a multiline Edit control

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © TechTwaddle | Powered by: