Solved

No Scrolling in RichEdit

Posted on 2001-07-04
18
757 Views
Last Modified: 2013-11-22
In RichEdit, I would like to keep whole text no scrolling when it is updated. How should I do.
0
Comment
Question by:ysimon
  • 6
  • 5
  • 4
  • +2
18 Comments
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
What do you mean with 'updated'?
0
 

Expert Comment

by:d32coder
Comment Utility
I know what he means..

In the RichEdit as with TMemo, when you programatically dump alot of text in the box the cursor goes to the end.
I believe he wants to reposition the cursor to it's original spot.

FROM THE HELP FILE
Read SelStart ...
If there is no selected text, SelStart indicates the position of the cursor. Set SelStart to remove the current selection and position the cursor just before the indicated character.

Try this ...

Richedit1.loadfromfile(blah.rtf');
Richedit1.SelStart := 0;


0
 

Expert Comment

by:d32coder
Comment Utility
Um...

Richedit1.loadfromfile(blah.rtf');
Richedit1.SelStart := 0;
RichEdit1.SelLength := 0; // avoid selecting text

Don
0
 

Author Comment

by:ysimon
Comment Utility
The text in RichEdit was written via a set of RichEdit1.Lines.Append('Text');
Another Update button will reload that set of RichEdit1.Lines.Append('Text');

Each time, it will go to the last line. I would like to keep the current viewing position. Is that possible?

ysimon
0
 
LVL 6

Expert Comment

by:edey
Comment Utility
I would add to the above:

with richEdit1.lines do
begin
 beginUpdate;
 append('text');
 selStart := 0;
 endUpdate;
end;

This way there is no rawing done until everything is finalized.

GL
Mike
0
 

Expert Comment

by:d32coder
Comment Utility

procedure addtext();
var cpos: integer;
 with Richedit1 do
  begin
  cpos := selstart; // get starting position
  Lines.Append('Text'); // add text
  SelStart := cpos; //reset starting position
  SelLength := 0; // no selected text when finished.
  end;
end;

** Edey: I trust that is important but I'm still kinda new, what might happen?

Don
0
 

Expert Comment

by:d32coder
Comment Utility

procedure addtext();
var cpos: integer;
 with Richedit1 do
  begin
  cpos := selstart; // get starting position
  Lines.Append('Text'); // add text
  SelStart := cpos; //reset starting position
  SelLength := 0; // no selected text when finished.
  end;
end;

** Edey: I trust that is important but I'm still kinda new, what might happen?

Don
0
 

Expert Comment

by:d32coder
Comment Utility
um, don't refresh after posting :)

ALSO note that there shouls be a ; after the

var cpos: integer;

The comma snuck in there.

Don
0
 

Author Comment

by:ysimon
Comment Utility
Have you tried

procedure addtext();
var cpos, I: integer;
with Richedit1 do
 begin
 cpos := selstart; // get starting position

 for I:=1 to 100 do
 Lines.Append('Text'); // add text

 SelStart := cpos; //reset starting position
 SelLength := 0; // no selected text when finished.
 end;
end;
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 6

Accepted Solution

by:
edey earned 50 total points
Comment Utility
I'm not sure what you mean, but if you're referring to the beginUpdate/endUpdate - well, nothing much happens if you don't have them.  The only thing they do is keep the control from updating when you mess with it's lines proeprty.  This way if you make alot of changes it doesn't waste time redrawing things a thousand times over.  Try something like this:

for ix := 0 to 10000 do
 memo1.text := memo1.text + chr(ord('a')+random(26));

then try it like so:

memo1.lines.beginUpdate;
for ix := 0 to 10000 do
 memo1.text := memo1.text + chr(ord('a')+random(26));
memo1.lines.endUpdate;

all these do is fill a memo with 10000 random a's, b's, c's etc.  The second, though, will be _much_ faster with -alot_ less flicker.

Your example prob. doesn't require such a speed optimization but the code does have a side benifit.  Because the control doesn't get all those extra updates no one can see the text get added, the memo scroll to the end, then scroll back up again (when you set selStart) - it'll look a lot cleaner.

GL
Mike
0
 

Expert Comment

by:d32coder
Comment Utility
Sweet.  Thanks for the tip  :)
0
 
LVL 6

Expert Comment

by:edey
Comment Utility
Glad to be of service :)

GL
Mike
0
 

Author Comment

by:ysimon
Comment Utility
If using

memo1.lines.beginUpdate;
memo1.Lines.Clear;
for ix := 0 to 1000 do
memo1.Lines.Append(chr(ord('a')+random(26));
memo1.lines.endUpdate;

Can it stop at the current viewing position?

ysimon

0
 
LVL 6

Expert Comment

by:edey
Comment Utility
Yup, the logic is the same as before:

memo1.lines.beginUpdate;
startPos := memo1.selStart;
for ix := 0 to 1000 do
memo1.Lines.Append(chr(ord('a')+random(26));
memo1.selStart := startPos;
memo1.lines.endUpdate;

GL
Mike
0
 

Author Comment

by:ysimon
Comment Utility
Yes, you are right.
In my case, it always goes to the end after For Loop.
I have to find why.

ysimon
0
 

Author Comment

by:ysimon
Comment Utility
I found why it always go to end. Because I set vertical scollbar. If set to None, like your example, it will stay at beginning. Any suggestion?

ysimon
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.11866558.html
http://www.experts-exchange.com/questions/Q.20107980.html
http://www.experts-exchange.com/questions/Q.20112507.html
http://www.experts-exchange.com/questions/Q.20121203.html
http://www.experts-exchange.com/questions/Q.20122370.html
http://www.experts-exchange.com/questions/Q.20128022.html
http://www.experts-exchange.com/questions/Q.20128024.html
http://www.experts-exchange.com/questions/Q.20143035.html
http://www.experts-exchange.com/questions/Q.20145949.html
http://www.experts-exchange.com/questions/Q.20164917.html
http://www.experts-exchange.com/questions/Q.20164983.html
http://www.experts-exchange.com/questions/Q.20171798.html
http://www.experts-exchange.com/questions/Q.20179154.html
http://www.experts-exchange.com/questions/Q.20192667.html
http://www.experts-exchange.com/questions/Q.20192583.html
http://www.experts-exchange.com/questions/Q.20200806.html
http://www.experts-exchange.com/questions/Q.20201786.html
http://www.experts-exchange.com/questions/Q.20201947.html
http://www.experts-exchange.com/questions/Q.20246959.html
http://www.experts-exchange.com/questions/Q.20252474.html
http://www.experts-exchange.com/questions/Q.20259886.html
http://www.experts-exchange.com/questions/Q.20270462.html
http://www.experts-exchange.com/questions/Q.20273241.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20265181.html
http://www.experts-exchange.com/questions/Q.20277546.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Zero response from anyone, finalized.
Moondancer - EE Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

10 Experts available now in Live!

Get 1:1 Help Now