The information in this article applies to:
SUMMARYWindows-based applications often use edit controls to display text. These applications sometimes need to append text to the end of an edit control instead of replacing the existing text. There are two different ways to do this in Windows:
MORE INFORMATION
NOTE: Because the message parameters for the EM_SETSEL message are
different between the 32-bit version and the 16-bit version, the following
code uses the Win32 macro to determine at build time if this is a 16- or 32-
bit application.
Once the caret is placed at end in the edit control, you can use the
EM_REPLACESEL to append text to the edit control. An application sends
an EM_REPLACESEL message to replace the current selection in an edit
control with the text specified by the lpszReplace (lParam) parameter.
Because there is no current selection, the replacement text is inserted at
the current caret location. This example sets the selection to the end of
the edit control and inserts the text in the buffer:
Another way to insert text into an edit control is to use the Windows
clipboard. If the application has the clipboard open or finds it convenient
to open the clipboard, and copies the text into the clipboard, then it can
send the WM_PASTE message to the edit control to append text. Of course,
any data that was in the clipboard will be lost.
Before sending the WM_PASTE message, the caret must be placed at the end of the edit control text using the EM_SETSEL message. Below is "pseudo" code that shows how to implement this method:
This "pseudo" code appends text to the end of the edit control. Note that
the data in the clipboard must be in CF_TEXT format.
Additional query words:
Keywords : kbCtrl kbEditCtrl kbNTOS kbWinOS2000 kbSDKWin32 kbGrpUser kbWinOS |
Last Reviewed: February 2, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |