PDA

View Full Version : Text Caret To End of Line



catventure
04-01-2009, 15:44
Hi All,

How do I move the flashing text caret (cursor) to the end of the text after I show the text in a single line textbox?

Thanks,
catventure.

ErosOlmi
04-01-2009, 16:16
Caret is visible only if the control has the focus.

Try something like


CONTROL SEND CBHNDL, %IDC_TEXTBOX, %EM_SETSEL, nStart, nEnd


If the start is 0 and the end is –1, all the text in the edit control is selected.
If the start is –1, any current selection is deselected.

To send to the end of the text try:


CONTROL SEND CBHNDL, %TEXTWINDOW, %EM_SETSEL, len(control_gettext(hDlg, %TEXTWINDOW)), -1


With the above line you are sending a message to the textbox telling to select from the end of the text to ... nothing. So caret will be positioned after the last char.

If you are using callbacks, use CBHNDL for window handler.
If not, change CBHNDL to the variable holding the window handler

Ciao
Eros

_________________________________________________
Reference: http://msdn.microsoft.com/en-us/library/bb761661(VS.85).aspx

catventure
04-01-2009, 17:27
Thanks Eros!

It worked perfectly.

Best regards,
catventure