The EM_SETSEL message changes the current text selection inside an edit control. Once this message sets the selection, the edit control's caret is placed immediately at the end of the selection.
This message does not return a meaningful value.
None.
Const EM_SETSEL = &HB1
' 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_setsel.html