?
Solved

How do I scroll a CRichEditCtrl?

Posted on 1999-08-18
8
Medium Priority
?
1,060 Views
Last Modified: 2013-11-20
I have an output window implemented, similar to Visual Studio's.  Right now, I use LineScroll() to manually scroll the control one line at a time.  What I really want to do, is always output text at the end of the buffer, and have it automatically scroll when it hits the bottom of the screen - like a CRichEditView will do if you output text to it.  Is there a way to do this with CRichEditCtrl?

Thanks,
-Matt Smith
0
Comment
Question by:matthewsmith
[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
  • 4
  • 4
8 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1314317
The following code works with an edit control. It should work with a rich edit control as well.

const int nLen = m_edit.GetWindowTextLength();
m_edit.SetSel(nLen, nLen);
m_edit.ReplaceSel(str);
0
 

Author Comment

by:matthewsmith
ID: 1314318
This will output text at the end of the buffer, which is part of what I want to do, but it does not automatically scroll it, which I need to do.  And ideally, the scrolling would be set up so that you could scroll back the buffer, and when you 'let go' of the scroll thumb, it would snap back to the bottom, where current text is being output.  Is there a way to do that?

thanks,
-Matt
0
 
LVL 23

Expert Comment

by:chensu
ID: 1314319
1. Try applying the ES_AUTOVSCROLL style.
2. Try calling LineScroll(numeric_limits<int>::max()) after ReplaceSel.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:matthewsmith
ID: 1314320
Applying the ES_AUTOVSCROLL doesn't seem to do anything special - it certainly doesn't allow the text to be auto-scrolled as the style implies.  Calling LineScroll(numeric_limits<int>::max()) will scroll the contents of the output window so that only the current line of output is shown at the very top of the window.  I want text to be output so that the current line is always output at the *bottom* of the screen, if you see what I mean.  I dealt with this by checking the line that's being output - if it contains a \n, I do a LineScroll(1).  This works reasonably well, except for a couple of things: If a line you output is longer than the window (I have word wrap turned off), A horizontal scroll bar will appear, which obscures the bottom line of text - you have to manually scroll down one line to see it.  The other problem is that if you scroll back in the buffer, you have to manually scroll back down to the bottom, and it's possible to scroll beyond the last line, so you have wacky problems like text being output in the middle of the screen.  Please let me know if that doesn't make sense.

thanks,
-Matt
0
 
LVL 23

Expert Comment

by:chensu
ID: 1314321
I know what you mean. My example at CodeGuru does it exactly except that it uses an edit control instead of a rich edit control. I just found a sample at

http://www.codeguru.com/richedit/dalrichedit.shtml

Try it to see if it works like what you want.
0
 

Author Comment

by:matthewsmith
ID: 2029075
None of these suggestions helped.
0
 
LVL 23

Accepted Solution

by:
chensu earned 400 total points
ID: 2029159
Try applying the EM_NOHIDESEL and EM_AUTOVSCROLL styles.
0
 

Author Comment

by:matthewsmith
ID: 2029249
Chensu:
 
   Actually, the styles are ES_NOHIDESEL, and ES_AUTOVSCROLL (I know, I'm nitpicking).  This works though!  It was the ES_NOHIDESEL that I hadn't tried.  Many, Many thanks!!!

cheers,
-Matt

0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

719 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