?
Solved

No Scrolling in RichEdit

Posted on 2001-07-04
18
Medium Priority
?
793 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
[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
  • 6
  • 5
  • 4
  • +2
18 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6253974
What do you mean with 'updated'?
0
 

Expert Comment

by:d32coder
ID: 6253977
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
ID: 6253978
Um...

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

Don
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ysimon
ID: 6254033
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
ID: 6254038
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
ID: 6254049

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
ID: 6254051

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
ID: 6254055
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
ID: 6254109
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
 
LVL 6

Accepted Solution

by:
edey earned 200 total points
ID: 6254232
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
ID: 6254259
Sweet.  Thanks for the tip  :)
0
 
LVL 6

Expert Comment

by:edey
ID: 6254290
Glad to be of service :)

GL
Mike
0
 

Author Comment

by:ysimon
ID: 6257180
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
ID: 6257948
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
ID: 6258038
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
ID: 6258113
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
ID: 6872390
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
ID: 7079709
Zero response from anyone, finalized.
Moondancer - EE Moderator
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 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