Mick
Mick

Reputation: 7937

Positioning cursor at the end of the text in a RichEdit control

I use the following code in an attempt to position the caret at the end of the text in a rich edit control:

    int len = GetWindowTextLength(editwin);
    SendMessage(editwin,EM_SETSEL,0,MAKELONG(len,len));

Unfortunately it appears to highlight (select) the entirety of the text. I can't figure out what I did wrong.

Upvotes: 0

Views: 1556

Answers (1)

David Heffernan
David Heffernan

Reputation: 612904

From the documentation for EM_SETSEL:

Parameters

wParam The starting character position of the selection.

lParam The ending character position of the selection.

So you need to pass len to both wParam and lParam.

Upvotes: 3

Related Questions