SetFocus after text

Sep 12, 2018 at 4:35pm
Hi, I made a txtfield form with text inside
i want to SetFocus into this txtfield but after the written texts

My problem:
When I setfocus, it aims in the editable form.. but not after the text that is already written.

Any hint to make setfocus after the already written text in the txtfield?
Sep 12, 2018 at 5:39pm
What GUI framework are you using? WinAPI? Something from Borland or MS? Something else?

A text widget (memo, edit field, etc) may have focus, but it also has a selection. Just setting the focus isn't enough. You must also set the selection, which is typically an index into the text and a (usually optional) character count.

[edit]
I found your other post.
http://www.cplusplus.com/forum/general/242399/

You'll need to send the EM_SETSEL message to the window.
https://docs.microsoft.com/en-us/windows/desktop/controls/em-setsel

Use SendMessage() to do it.
https://www.google.com/search?btnI=1&q=msdn+sendmessage

Hope this helps.
Last edited on Sep 12, 2018 at 5:43pm
Sep 12, 2018 at 5:45pm
Hmm not sure i'm really dumb lol,
well, I use CreateWindowEx "WinUser.h" a win32 project
Sep 12, 2018 at 6:06pm
you should be able to get the length of the text in the box currently and set the position to the end that way, if there isnt a direct function to do that. There should be some sort of cursor position or cursor location type value that you can set. This should not require a message (though you can do it that way).
Last edited on Sep 12, 2018 at 6:07pm
Sep 12, 2018 at 6:17pm
Thank you!!!!!! WORKED <3
Topic archived. No new replies allowed.