How can I set the cursor position in an edit box?
By default, when you insert text into a multi line textbox, the cursor is updated. But what I want to do is to set the cursor at the origin (row 1, col1), AFTER I filled the editbox with text.

Posted on 2005-02-10 08:59:18 by bszente
Good question... I wonder if SetCaretPos(0,0) would achieve what you want.
Posted on 2005-02-10 09:15:01 by JimmyClif
I tested SetCaretPos. Unfortunately it's not working.
The problem is that the parameters for this function are actually in pixels.
For example if I call SetCaretPos(10,10) it actually will move the cursor at pixel coordinates (10,10) and not character coordinates.
And after it if I press for example the up-arrow key, the cursor will jump back to orginial location and moves up a line.

I have no ideea how to solve this.
Posted on 2005-02-10 10:24:04 by bszente
Weird, I wrote a little tool and set some text inside an Edit and the Cursor stayed at the beginning.

But anyways, using invoke SendMessage,hEdit,EM_SETSEL,0,0 I was able to set it to the first line after moving the caret around.
Posted on 2005-02-10 11:56:14 by JimmyClif
You have right, when you write something in an edit box, the cursor remains at origin. I was wrong. However when you do invoke SendMessage,hEdit,EM_SETSEL,0,-1, then moves the cursor at the end. But this is the point where I want to set the cursor to a new location (origin).

Thanks anyway.
Posted on 2005-02-10 12:06:28 by bszente