Solved

No Scrolling in RichEdit

Posted on 2001-07-04
18
763 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Accepted Solution

by:
edey earned 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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 Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

920 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

15 Experts available now in Live!

Get 1:1 Help Now