English 中文(简体)
Setting carret-position in an External Application s text area?
原标题:

Thanks to Rob Kennedy s answer to my question on how to set the Skype Chat window text.

However, whenever I set the text using

SendMessage(RichEditWnd,WM_SETTEXT,0,Integer(PChar(Edit1.Text)));

Then when I click on the Chat Edit control in Skype, the carret is placed at the beginning and some clicking is required to get it "right" again.

Is there a Windows Message for setting the carret position? Or atleast something that I can use to set the Carret Position to the end of the text? :)

最佳回答

Yes, there is: EM_EXSETSEL.

wParam should be 0, and lParam should be a pointer to a TCharRange structure containing the first and last characters in the selection. You want these to be equal (that is, zero characters selected).

For instance,

var
  cr: TCharRange;
begin
  cr.cpMin := 2;
  cr.cpMax := 2;
  SendMessage(RichEdit1.Handle, EM_EXSETSEL, 0, integer(@cr));

will set the caret just before the third character in the Rich Edit control.

问题回答

暂无回答




相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签