Programmatically scroll CEdit in a dialog? 
Author Message
 Programmatically scroll CEdit in a dialog?

I should know how to do this, but I don't.  I have a dialog app that
contains a CEdit control which has a vertical scroll bar and the auto
vertical scroll attributes set.

After I put text into the control using SetWindowText, I need to ensure that
the last line of text is visible at the bottom of the CEdit control.  I've
played with CEdit::Linescroll and also with deriving a class from CEdit and
simulating the page down keyboard message.  No luck so far.

I'm sure there is an easy way to put text into a CEdit and then
programmatically  scroll it so as to display the last line of text at the
bottom of the display.  Can anyone please pass me a pointer or a clue?

thanks

Jim



Mon, 07 Mar 2005 15:16:48 GMT  
 Programmatically scroll CEdit in a dialog?
I'd give CEdit::SetSel(...) a shot.  I believe SetSel(-1, -1) will set the
cursor to the end of the text.  SetSel has a parameter to indicate whether
the caret should be scrolled into view.

TFM3

Note: Spam-resistant e-mail address


Quote:
> I should know how to do this, but I don't.  I have a dialog app that
> contains a CEdit control which has a vertical scroll bar and the auto
> vertical scroll attributes set.

> After I put text into the control using SetWindowText, I need to ensure
that
> the last line of text is visible at the bottom of the CEdit control.  I've
> played with CEdit::Linescroll and also with deriving a class from CEdit
and
> simulating the page down keyboard message.  No luck so far.

> I'm sure there is an easy way to put text into a CEdit and then
> programmatically  scroll it so as to display the last line of text at the
> bottom of the display.  Can anyone please pass me a pointer or a clue?

> thanks

> Jim



Mon, 07 Mar 2005 16:06:01 GMT  
 Programmatically scroll CEdit in a dialog?
Hi Jim

On Thu, 19 Sep 2002 09:16:48 -0500, "Jim Howard"

Quote:

>After I put text into the control using SetWindowText, I need to ensure that
>the last line of text is visible at the bottom of the CEdit control.

I had the same problem, the only solution I found was:

void CMyDialog::OnPaint ()
{
  CPaintDC dc (this);
  DWORD dwSel = mEditCtrl.GetSel ();
  mEditCtrl.SetSel (HIWORD (dwSel), -1);

Quote:
}

HTH

Best regards
Walter



Mon, 07 Mar 2005 16:12:05 GMT  
 Programmatically scroll CEdit in a dialog?
CEdit::LineScroll?
                        joe

Quote:

>I should know how to do this, but I don't.  I have a dialog app that
>contains a CEdit control which has a vertical scroll bar and the auto
>vertical scroll attributes set.

>After I put text into the control using SetWindowText, I need to ensure that
>the last line of text is visible at the bottom of the CEdit control.  I've
>played with CEdit::Linescroll and also with deriving a class from CEdit and
>simulating the page down keyboard message.  No luck so far.

>I'm sure there is an easy way to put text into a CEdit and then
>programmatically  scroll it so as to display the last line of text at the
>bottom of the display.  Can anyone please pass me a pointer or a clue?

>thanks

>Jim

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Mon, 07 Mar 2005 17:14:11 GMT  
 Programmatically scroll CEdit in a dialog?
I was already using one LineScroll per \r\n in the CEdit's text, but it
turned out that to ensure the text scrolled all the way to the bottom I
could just send one screen worth of scroll commands after the last bit of
text is added.  Fortunately, LineScroll won't scroll the text past the end
of text in a CEdit control.

Thanks fellows for the free clues.

Jim Howard



Quote:
> CEdit::LineScroll?



Tue, 08 Mar 2005 18:06:28 GMT  
 Programmatically scroll CEdit in a dialog?
There is also a question as to whether or not an edit control is what you want here;
depending on what you are trying to accomplish, sometimes a listbox is a better output
medium (for example, for logging of output). Note that you don't always want to force the
last linet to display. There are few things more offensive than a control that I scroll
back to read only to have it ripped away from me so some last line can become visible. You
might want to study the logic of my logging listbox, which allows the user to scroll the
display back, but if the user scrolls to the end, the autoscrolling resumes.
                                        joe

Quote:

>I was already using one LineScroll per \r\n in the CEdit's text, but it
>turned out that to ensure the text scrolled all the way to the bottom I
>could just send one screen worth of scroll commands after the last bit of
>text is added.  Fortunately, LineScroll won't scroll the text past the end
>of text in a CEdit control.

>Thanks fellows for the free clues.

>Jim Howard



>> CEdit::LineScroll?

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Fri, 11 Mar 2005 08:44:49 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. how:hide CListCtrl scroll bar and scroll programmatically

2. Scrolling problems with CEdit - Multiline on a dialog

3. Scrolling problems with CEdit - Multiline on a dialog

4. Programmatically scrolling IE4 windows (Where is WM_SCROLL?)

5. Programmatically scrolling IE4 windows (Where is WM_SCROLL?)

6. how to programmatically scroll an edit control ...

7. Scrolling programmatically

8. Programmatically scrolling IE4 windows (Where is WM_SCROLL?)

9. CEdit Box Programmatically Updated

10. CEdit Scrolling

11. CEdit Scroll by code

12. CEdit scrolling

 

 
Powered by phpBB® Forum Software