Solved

How to scroll richedit smoothly?

Posted on 2000-02-22
10
1,293 Views
Last Modified: 2013-11-22
ScrollBy function can only scrool the visible part of the richedit component,and richedit.perform(WM_VSCROLL,SB_LINEDOWN,0) can only scroll it by one line.
I want to scroll it smoothly,how to do it?
0
Comment
Question by:limin_chen
10 Comments
 

Expert Comment

by:mike_tipping
ID: 2546380
Place the richedit in a panel and increase the size of the richedit box to the full length of the RE document (either at design time or dinamically according to what is load into it). Only the section of the REB in the pannelo will be visible but if you increase and devrease the value of the rich edits top property the richedir box will slide up and down within the panel and give the impression of scrolling.

This may sound a bit of a cheat but it's the only way I could find to do it and it has worked fine so far.
0
 
LVL 6

Expert Comment

by:edey
ID: 2546603
Another method would be to keep a full sized, hidden, rich edit, draw the thing to an off screen bmp and blt chunks of it to a scrollable control.  Note, this would work *muc* better with a read-only rich edit, in this case you wouldn't even have to keep the rich edit at all


Gl
Mike
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2547018
listenning
0
 

Author Comment

by:limin_chen
ID: 2548498
To edey:
  I like your method more.
  But if the richedit box is invisible or if it was created in program,the program here:
var
    back:tbitmap;
begin
  back:=tbitmap.create;
  back.canvas.width:=richedit.width;
  back.canvas.heigth:=richedit.height;
  bitblt(back.canvas.handle,0,0,back.canvas.width,back.canvas.height,getdc(richedit.handle),0,0,SRCCOPY);
  bitblt(mainform.canvas.handle,0,0,richedit.width,richedit.height,back.canvas.handle,0,0,SRCCOPY);
end;
  It could not get the correct image of the current richedit box,It is just filled with white color.I dont know the reason.
0
 

Author Comment

by:limin_chen
ID: 2548888
Mike tipping:
  could you please tell me how to get the full lenght of the RE document displayed in RE box?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Expert Comment

by:mike_tipping
ID: 2549568
Increase The Height, the following code is probably not a brilliant as it could be but it works. Hide the Richedit box or Panel, and set

richedit1.height := Reditlength;

Then Show whichever you hid. If you don't do this you se the Reditlength function scanning the text.



Function TForm1.Reditlength;
Var
  nHeight, i, nSelStart : Integer;
Begin
  nSelStart := 1;
  {character to start scanning from}
  nHeight := 6;{this is the gap
                before the first text}
  For i:= 0 to Pred(Richedit1.Lines.Count) do
  begin
    Richedit1.SelStart := nSelStart;
    Richedit1.SelLength := 5;
    {scan 5 Characters in each line}
    nHeight := nHeight + RichEdit1.SelAttributes.Height + 3;
    {+3 for the gap between lines}
    nSelStart := nSelStart + Length(Richedit1.Lines.Strings[1]);
  end{for};
  REditLength := nHeight;
End;
0
 

Author Comment

by:limin_chen
ID: 2549671
I found a better method to get the actul lines in pixel.Does it work right?

var
  h:integer;
begin
 richedit.peform    (wm_vscroll,sb_bottom,0);
 h:=getscrollpos(richedit.handle,sb_vert);
 inc(h,richedit.height);
{So ,I think the var h is the total lines in pixel}
0
 

Expert Comment

by:mike_tipping
ID: 2550102
It looks like this gives the position on the screen of the scroll bar toggle (thumb), not the length on the rich edit box

I presume your trying to scroll the richedit box with scroll bars switched off which would mean that getscrollpos returns 0 as there are no scroll 'thumbs' to get the position of.

I guess with ebey's solution your going to need to expand the rich edity box to it's full height as well, which gives us the same problem, how to get the length of the contents of the richedit box in pixels.
0
 
LVL 1

Expert Comment

by:duke_n
ID: 2550450
Var
Line:integer;
begin
Line:=20;//or something
SendMessage(RE.Handle, EM_LINESCROLL,0,MAKELONG(word(Line-(GetScrollPos(RE.Handle,SB_VERT)div 13)),0));//13-My Richedit's linesize
end;

this one works smoothly for me
0
 

Accepted Solution

by:
mike_tipping earned 100 total points
ID: 2564421
so who gets the points?
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now