EM_REPLACESEL Message

Platforms

Description & Usage

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.

Return Value

This message does not return a meaningful value.

Visual Basic-Specific Issues

None.

Parameters

wParam
Specifies whether the text replacement should be added to the edit control's Undo list, which would allow the user to undo the operation. A nonzero value allows an undo; a value of 0 does not.
lParam
The text to replace the selection with. If nothing in the edit control is selected, this text is inserted at the current position of the caret.

Constant Definitions

Const EM_REPLACESEL = &HC2

Example

' 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")

See Also

EM_GETSEL, EM_SETSEL

Category

Edit Controls

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