[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to scroll richedit smoothly?

Posted on 2000-02-22
10
Medium Priority
?
1,341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
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!

 

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
 

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 200 total points
ID: 2564421
so who gets the points?
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

656 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