Board index » delphi » Scrolling a TMemo?

Scrolling a TMemo?

Hi all,

Sorry if someone else has already asked this, but... Is it possible to
scroll the box to a specific line in a TMemo. As in scroll(10) would scroll
to the tenth line in the TMemo.

Thanks in advance,

Nick

 

Re:Scrolling a TMemo?


Quote
Nicholas Sherlock wrote in message <9ssqah$g0...@lust.ihug.co.nz>...
>Hi all,

>Sorry if someone else has already asked this, but... Is it possible to
>scroll the box to a specific line in a TMemo. As in scroll(10) would
scroll
>to the tenth line in the TMemo.

You can do this by sending it Windows messages. WM_SCROLL_CARET
scrolls to the cursor position, for example. What you want is
different and I don't know the message for it, but it could well
exist.

Perhaps the help file has some pointers from WM_SCROLL_CARET to
what you need; perhaps reading through messages.pas would help
(but it's rather a long read).

Groetjes,
Maarten Wiltink

Re:Scrolling a TMemo?


I want to do the same thing with a search option in my prog, but I strangely
can't find WM_SCROLL_CARET in the Win32 help files. How should i call it? I
get an "Undeclared Identifier" when trying to compile. I have Windows,
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ToolWin,
ComCtrls, StdCtrls, ExtCtrls; in the uses clause. Do i miss something?
(Using D4).
Memo1.CaretPos is Read only, so i also can't set this value.

Hope someone can help us.
Louis

"Maarten Wiltink" <maar...@kittensandcats.net> schreef in bericht
news:9st7id$poi$1@news1.xs4all.nl...

Quote
> Nicholas Sherlock wrote in message <9ssqah$g0...@lust.ihug.co.nz>...
> >Hi all,

> >Sorry if someone else has already asked this, but... Is it possible to
> >scroll the box to a specific line in a TMemo. As in scroll(10) would
> scroll
> >to the tenth line in the TMemo.

> You can do this by sending it Windows messages. WM_SCROLL_CARET
> scrolls to the cursor position, for example. What you want is
> different and I don't know the message for it, but it could well
> exist.

> Perhaps the help file has some pointers from WM_SCROLL_CARET to
> what you need; perhaps reading through messages.pas would help
> (but it's rather a long read).

> Groetjes,
> Maarten Wiltink

Re:Scrolling a TMemo?


"Louis Somers" <lsom...@NOSPAMconceptfsa.nl> skrev i melding
news:9t9fds$1bu6$1@scavenger.euro.net...

Quote
> I want to do the same thing with a search option in my prog, but I
strangely
> can't find WM_SCROLL_CARET in the Win32 help files. How should i call it? I
> get an "Undeclared Identifier" when trying to compile. I have Windows,

try WM_SCROLLCARET...

--
Bjoerge Saether
Consultant / Developer
http://www.itte.no
Asker, Norway
bjorge@takethisaway_itte.no (remve the obvious)

Re:Scrolling a TMemo?


I found it!

Var Position: integer;
Begin
Position := 10;
SendMessage(Memo1.Handle, WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, Position),
0);
end;

Thanks anyway :-)

"Bj?rge S?ther" <REMOVE_bsaether@THIS_online.no> schreef in bericht
news:0zXJ7.4100$B87.65955@news1.oke.nextra.no...

Quote
> "Louis Somers" <lsom...@NOSPAMconceptfsa.nl> skrev i melding
> news:9t9fds$1bu6$1@scavenger.euro.net...
> > I want to do the same thing with a search option in my prog, but I
> strangely
> > can't find WM_SCROLL_CARET in the Win32 help files. How should i call
it? I
> > get an "Undeclared Identifier" when trying to compile. I have Windows,

> try WM_SCROLLCARET...

> --
> Bjoerge Saether
> Consultant / Developer
> http://www.itte.no
> Asker, Norway
> bjorge@takethisaway_itte.no (remve the obvious)

Re:Scrolling a TMemo?


Quote
"Louis Somers" <lsom...@NOSPAMconceptfsa.nl> wrote in message

news:9t9fds$1bu6$1@scavenger.euro.net...
Quote
> I want to do the same thing with a search option in my prog, but I
strangely
> can't find WM_SCROLL_CARET in the Win32 help files. How should i call it?
I
> get an "Undeclared Identifier" when trying to compile. I have Windows,
> Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ToolWin,
> ComCtrls, StdCtrls, ExtCtrls; in the uses clause. Do i miss something?
> (Using D4).
> Memo1.CaretPos is Read only, so i also can't set this value.

> Hope someone can help us.
> Louis

sorry if this is a duplicate..Australia's largest ISP 'Telstra Bigpond'
aka 'BogPond' 'WetSpot''PondScum' 'TeleTubbies' et al
continues its experiments in catastrophy theory

edit message??
EM_SCROLLCARET

to search you can use multiple words in find
use index then the 'find' tab
scroll caret
gives a likely suspect ;-)

In general, but not in this case ,some of the indexes in w32 help
are not right. Some subjects can only be accessed by the roundabout
way of paging forward/back from nearby items in the same group .

It is also listed in sources/rtl/win/messages.pas
under the edit control messages section

greppas.bat
=====
grep -i -d %1 c:\your\source\path\*.pas | more

Re:Scrolling a TMemo?


Quote
Louis Somers wrote in message <9tbji7$241...@scavenger.euro.net>...
>I found it!

>Var Position: integer;
>Begin
>Position := 10;
>SendMessage(Memo1.Handle, WM_VSCROLL, MAKELONG(SB_THUMBPOSITION,
Position),
>0);
>end;

Good! (Final hint: TControl.Perform)

Groetjes,
Maarten Wiltink

Re:Scrolling a TMemo?


Ah EM_, instead of WM_... hehe, should have thought of searching fro the
words instead of the command.
I also didn't know i had the Grep command in Windows. Super!

"Terry Russell" <trochi...@bigpond.com> schreef in bericht
news:9tbu86$1ll2k$1@ID-104513.news.dfncis.de...

Quote
> "Louis Somers" <lsom...@NOSPAMconceptfsa.nl> wrote in message
> news:9t9fds$1bu6$1@scavenger.euro.net...
> > I want to do the same thing with a search option in my prog, but I
> strangely
> > can't find WM_SCROLL_CARET in the Win32 help files. How should i call
it?
> I
> > get an "Undeclared Identifier" when trying to compile. I have Windows,
> > Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ToolWin,
> > ComCtrls, StdCtrls, ExtCtrls; in the uses clause. Do i miss something?
> > (Using D4).
> > Memo1.CaretPos is Read only, so i also can't set this value.

> > Hope someone can help us.
> > Louis
> sorry if this is a duplicate..Australia's largest ISP 'Telstra Bigpond'
> aka 'BogPond' 'WetSpot''PondScum' 'TeleTubbies' et al
> continues its experiments in catastrophy theory

> edit message??
> EM_SCROLLCARET

> to search you can use multiple words in find
> use index then the 'find' tab
> scroll caret
> gives a likely suspect ;-)

> In general, but not in this case ,some of the indexes in w32 help
> are not right. Some subjects can only be accessed by the roundabout
> way of paging forward/back from nearby items in the same group .

> It is also listed in sources/rtl/win/messages.pas
> under the edit control messages section

> greppas.bat
> =====
> grep -i -d %1 c:\your\source\path\*.pas | more

Re:Scrolling a TMemo?


Thanks, didn't know about 'Perform'.

Memo1.Perform(WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, Position), 0);

or:

Memo1.SelStart := Position;
Memo1.Perform(EM_SCROLLCARET, 0, 0);

Works slightly better because you don't have to find out the line number
before calling.

"Maarten Wiltink" <maar...@kittensandcats.net> schreef in bericht
news:9tbv0c$h1n$1@news1.xs4all.nl...

Quote
> Louis Somers wrote in message <9tbji7$241...@scavenger.euro.net>...
> >I found it!

> >Var Position: integer;
> >Begin
> >Position := 10;
> >SendMessage(Memo1.Handle, WM_VSCROLL, MAKELONG(SB_THUMBPOSITION,
> Position),
> >0);
> >end;

> Good! (Final hint: TControl.Perform)

> Groetjes,
> Maarten Wiltink

Re:Scrolling a TMemo?


Quote
"Louis Somers" <lsom...@NOSPAMconceptfsa.nl> wrote in message

news:9tejae$1uef$1@scavenger.euro.net...

Quote
> Ah EM_, instead of WM_... hehe, should have thought of searching fro the
> words instead of the command.
> I also didn't know i had the Grep command in Windows. Super!

it is in the delphi\bin directory, D3 doesn't have it
borland C has had a grep for a while

Re:Scrolling a TMemo?


Quote
Louis Somers wrote in message <9tejo9$26c...@scavenger.euro.net>...
>Thanks, didn't know about 'Perform'.

>Memo1.Perform(WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, Position), 0);

>or:

>Memo1.SelStart := Position;
>Memo1.Perform(EM_SCROLLCARET, 0, 0);

>Works slightly better because you don't have to find out the line number
>before calling.

You're welcome, etc. The WM_SCROLL_CARET instead of EM_SCROLLCARET
was an honest mistake on my part, but I'm pleased you found the
answer anyway.

Groetjes,
Maarten Wiltink

Re:Scrolling a TMemo?


In article <9tejo9$26c...@scavenger.euro.net>, "Louis Somers"

Quote
<lsom...@NOSPAMconceptfsa.nl> writes:
>Thanks, didn't know about 'Perform'.

TControl.Perform send the message directly to that control's windows proc,
SendMessage(handle, ... sends the message to that windows proc and does not
return until the message has been processed, PostMessage(handle, ... puts the
message in that windows messgae queue and returns immediately.

Alan Lloyd
alangll...@aol.com

Other Threads