The EM_REPLACESEL message tells an edit control to replace the currently selected text with a different string. If nothing in the edit control is selected, then the text is instead inserted at the position of the caret.
This message does not return a meaningful value.
None.
Const EM_REPLACESEL = &HC2
' This code is licensed according to the terms and conditions listed here.
' Declarations and such needed for the example:
' (Copy them to the (declarations) section of a module.)
Public Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd _
As Long, ByVal Msg As Long, wParam As Any, lParam As Any) As Long
Public Const EM_REPLACESEL = &HC2
Public Const EM_SETSEL = &HB1
' Select the first five characters in edit control Text1. Then replace the newly
' selected text with the words "REPLACEMENT TEXT".
Dim retval As Long ' return value
' First, select the first five characters of Text1.
retval = SendMessage(Text1.hWnd, EM_SETSEL, ByVal CLng(0), ByVal CLng(5))
' Then replace the selection with some other text. Allow the user to undo it.
retval = SendMessage(Text1.hWnd, EM_REPLACESEL, ByVal CLng(1), ByVal "REPLACEMENT TEXT")
Back to the Message list.
Back to the Reference section.
Last Modified: May 21, 2000
This page is copyright © 2000 Paul Kuliniewicz.
Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/e/em_replacesel.html