Solved

Scrolling in a Rich Edit control (again...!)

Posted on 1998-01-09
2
406 Views
Last Modified: 2013-11-20
  (This problem was posted before, but the solution that I decided to used is not working on every system!)

   OK...  First the long description:

   When I add text to a Rich Edit control, most of the time, it will not scroll to the added text, so I have to manually scroll to make it visible.  The problem is, I am able to scroll down so far that no lines are visible (but the API docs tell me that I cannot do this!)

   What I need to do is add text, via StreamIn(), and scroll it so that the added text is visible.

   Here are the problems:

   The size of the Rich Edit control area is variable, at runtime, and the fonts and font-sizes used in the Rich Edit control are variable as well.

   Now, the short description:

   If you scroll (via code) a Rich Edit control so that only one line is visible at the TOP, and then click (not move) the scrollbar, the control will adjust itself so that the last line is the last visible line.  That is what I need: a way to make the last line in the control the last visible line, every time.

   Lastly, a request:  The last time I had this problem, I got some responses that obviously were not tested, or the question was not understood.  I promise not to waste your time, if you do not waste mine! :)

   Thanx!

-=- James.
0
Comment
Question by:jtwine100697
2 Comments
 
LVL 2

Accepted Solution

by:
anichini earned 200 total points
ID: 1313677
Put the following code in your rich edit view class and it'll do what you want.

SCROLLINFO info;

info.cbSize = sizeof(SCROLLINFO);

GetScrollInfo(SB_VERT, &info, SIF_RANGE);

SendMessage(WM_VSCROLL, MAKELPARAM(SB_THUMBTRACK, info.nMax), NULL);
SendMessage(WM_VSCROLL, MAKELPARAM(SB_THUMBPOSITION, info.nMax), NULL);
SendMessage(WM_VSCROLL, MAKELPARAM(SB_ENDSCROLL, 0), NULL);

I tested this particular case, but I think it is unrealistic for people to expect experts to test every detail of every answer. The experts have jobs, too, you know - most of the time we can only give guidance to what we know is the correct answer, but it still requires some work on the questioner's part. I think if most people went into EE just expecting some guidance instead of hard and fast answers, there would be a lot less misunderstandings.

0
 
LVL 4

Author Comment

by:jtwine100697
ID: 1313678
  This is EXACTLY what I am looking for...  Much thanx!

   And, BTW: the comment at the end of my question was not meant to offend.  I, too, have a job, and have been programming for quite some time.  I only wrote that comment as it prevents a constant exchange of information, and thus a waste of time.

   Note that I do not ask others to do something unless I would not do it myself: When I *answer* questions, it is because I am pretty sure of my answer; I am not asking others to test my theory.  (See my previous answer on sharing CMap-using-classes across multiple threads.)  When I *comment* on them, that is because I am offering a suggestion, not a fix!

   Thanx again for your time.

-=- James
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

Title # Comments Views Activity
How to create frequencies of a variable from SAS dataset? 10 121
repeatEnd java challenge 42 84
Define unique primary key 9 89
ffmpeg - "rtsp://...... Operation not permitted" 4 74
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

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

13 Experts available now in Live!

Get 1:1 Help Now