Board index » delphi » How to position textcursor within texfield?

How to position textcursor within texfield?

Hi,

I want to add a "Go to line"-function to my program but I don't know how to
place the textcursor within a RichEdit field to the given line. Does anyone
know how to do this?

Thanks in advance

Dennis Schramm
www.dennis-schramm.com

 

Re:How to position textcursor within texfield?


Hi Dennis,

Quote
>I want to add a "Go to line"-function to my program but I don't know how to
>place the textcursor within a RichEdit field to the given line. Does anyone
>know how to do this?

Read Win32-OLH about EM_SCROLL message and similar.
Wasn't your question already answered in a german group, you posted to?

Cheers,
   Udo
--
Homepage: http://www.nesshoever.de            No mails please. Reply here.

Delphi env.:                         Global Polio Awareness Campaign 2001+
W2K.sp2, D6Pro & D4Pro.sp3               More info -> http://www.2-mad.com

Re:How to position textcursor within texfield?


Quote
> Wasn't your question already answered in a german group, you posted to?

Yeah, but the sample-program didn't work properly.

Re:How to position textcursor within texfield?


Try:

uses
  CommCtrl;

procedure GotoLine(RichEdit: TRichEdit; Line: Integer);
var
  Pos: Integer;
begin
  Pos := RichEdit.Perform(EM_LINEINDEX, Line, 0);
  RichEdit.Perform(TBM_SETSEL, Integer(True), MakeLong(Pos, Pos));
  RichEdit.SelStart := Pos;
  RichEdit.Perform(EM_SCROLLCARET, 0, 0);
end;

"Dennis Schramm" <dennis_schr...@hotmail.com> schreef in bericht
news:9j7csm$mif3k$1@ID-78164.news.dfncis.de...

Quote
> Hi,

> I want to add a "Go to line"-function to my program but I don't know how
to
> place the textcursor within a RichEdit field to the given line. Does
anyone
> know how to do this?

> Thanks in advance

> Dennis Schramm
> www.dennis-schramm.com

Other Threads