{"id":231,"date":"2009-10-12T23:14:02","date_gmt":"2009-10-12T17:44:02","guid":{"rendered":"http:\/\/techtwaddle.net\/?p=231"},"modified":"2011-04-12T23:14:30","modified_gmt":"2011-04-12T17:44:30","slug":"applications-appending-text-to-a-multiline-edit-control","status":"publish","type":"post","link":"https:\/\/techtwaddle.co.in\/blog\/2009\/10\/12\/applications-appending-text-to-a-multiline-edit-control\/","title":{"rendered":"Applications: Appending text to a multiline Edit control"},"content":{"rendered":"<div style=\"text-align: justify; font-family: Comic Sans MS;\">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. <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">WM_SETTEXT<\/span> was overwriting the previous contents. And doing a <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">WM_GETTEXT<\/span> first, appending to it and then <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">WM_SETTEXT<\/span> seemed like an overkill.<\/div>\n<p>&nbsp;<\/p>\n<div style=\"text-align: justify; font-family: Comic Sans MS;\">A little bit of searching led me to <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/aa929135.aspx\"><span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">EM_REPLACESEL<\/span><\/a> message. This message is used to replace the currently selected text in the edit control with the specified text but there&#8217;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 <span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">SETCARETPOS<\/span> message. So anyways, here&#8217;s how to append text in an edit control:<\/div>\n<p><br style=\"font-family: Comic Sans MS;\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">HWND hWndEdit = GetDlgItem(g_hDlg, IDC_EDIT_BOX);<\/span><br \/>\n<br style=\"font-family: Verdana; color: rgb(0, 0, 128);\" \/><br \/>\n<span style=\"font-family: Verdana; color: rgb(0, 0, 128);\">SendMessage(hWndEdit, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)str);<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/techtwaddle.co.in\/blog\/2009\/10\/12\/applications-appending-text-to-a-multiline-edit-control\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Applications: Appending text to a multiline Edit control<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1ktFF-3J","_links":{"self":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/231"}],"collection":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/comments?post=231"}],"version-history":[{"count":1,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/231\/revisions"}],"predecessor-version":[{"id":232,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/posts\/231\/revisions\/232"}],"wp:attachment":[{"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/media?parent=231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/categories?post=231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtwaddle.co.in\/blog\/wp-json\/wp\/v2\/tags?post=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}