• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 181
  • Last Modified:

Setting the mouse position of a textbox.

Hey, this is what I want to do.

I have the handle of another textbox of another program. When I edit the text of that textbox by doing a SETTEXT on the handle then the mouse position goes to 0 (i.e: to the beginnen of the text), what I want is to send a message after the SETTEXT so that the mouse position goes to the end of the text like it was.

Thnx!
0
JimmyJJ
Asked:
JimmyJJ
  • 2
  • 2
1 Solution
 
Imthiyaz_phCommented:
do you want to set the mouse position or the text caret ?
0
 
JimmyJJAuthor Commented:
Yup the last thing you mentioned. Any ideas?

Thnx!
0
 
geobulCommented:
Hi,

Try this:

var
  h: THandle;
  s: string;
begin
  s := 'text for setting';
  h := .. // get the handle
  ... //send WM_SETTEXT here
  SendMessage(h, EM_SETSEL, Length(s), Length(s));
  SendMessage(h, EM_SCROLLCARET, 0, 0);

Regards, Geo
0
 
geobulCommented:
EM_SETSEL will position the cursor at the end of the text
EM_SCROLLCARET will scroll to the cursor in a multiline control
0
 
JimmyJJAuthor Commented:
Hey, thnx man!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now