15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Rich edit control scrolling

Brad Wilson/Crucial Software -- crucial@pobox.com
Wednesday, November 13, 1996

Environment: VC++ 4.2-flat, MFC 4.2, Windows NT 4.0

I'm using a rich edit control (placed on the dialog using the MS Richtext
OCX, and wrapped up in a CRichtext control).  I'm adding text to the edit
control, which does not have the focus.  The purpose of the edit control is
only to contain text output; the user will not be typing in the control.

With a traditional edit control, I was doing this:

	m_myEdit.SetCurSel( 0x7fff, 0x7fff );
	m_myEdit.ReplaceSel( "this is additional text" );

This moves the cursor to the end, eliminating all selections, and adds the
text to the control.  With the CRichedit control, I am doing:

	m_myRichedit.SetSelStart( 0x7fff );
	m_myRichedit.SetSelText( "this is additional text" );

Okay, the text adds okay.  With the edit control, I got automatic vertical
scrolling, which is what I want.  With the rich edit control, I do -not-
get automatical vertical scrolling.  There are no attributes of the OCX
which indicate automatic vertical scrolling.

Does anyone know how I can fix this?

--
Brad Wilson                       Custom software development & solutions
crucial@pobox.com               Internet and intranet consulting services
The Brads' Consulting          Windows NT/Windows 95 software development
http://www.thebrads.com    Web site planning, development and maintenance




Knut Magne Risvik -- kmr@foa.unit.no
Tuesday, November 26, 1996

Environment: VC4.1 flat, Win95

On Wed, 13 Nov 1996, Brad Wilson wrote:

> I'm using a rich edit control (placed on the dialog using the MS Richtext
> OCX, and wrapped up in a CRichtext control).  I'm adding text to the edit
> control, which does not have the focus.  The purpose of the edit control is
> only to contain text output; the user will not be typing in the control.
> 
> 	m_myRichedit.SetSelStart( 0x7fff );
> 	m_myRichedit.SetSelText( "this is additional text" );
> 

Sending a EM_SCROLLCARET should scroll the caret into view. However, this
does not work. Does anybody know what the problem might be?

- Knut Magne Risvik.





Brad Wilson/Crucial Software -- crucial@pobox.com
Thursday, November 28, 1996

> On Wed, 13 Nov 1996, Brad Wilson wrote:
>
> > I'm using a rich edit control (placed on the dialog using the MS
Richtext
> > OCX, and wrapped up in a CRichtext control).  I'm adding text to the
edit
> > control, which does not have the focus.  The purpose of the edit
control is
> > only to contain text output; the user will not be typing in the
control.
> > 
> > 	m_myRichedit.SetSelStart( 0x7fff );
> > 	m_myRichedit.SetSelText( "this is additional text" );
> 
> Sending a EM_SCROLLCARET should scroll the caret into view. However, this
> does not work. Does anybody know what the problem might be?

It appears that the ES_NOHIDESEL flag is the culprit here.  When this flag
is on, the scrolling is normal.  When this flag is off, the scrolling
doesn't happen until the control gets the focus.

Why it works this way, I don't know.  And now I've forgotten who gave me
the solution.  So, thanks to that person (he knows who he is :).

--
Brad Wilson                       Custom software development & solutions
crucial@pobox.com               Internet and intranet consulting services
The Brads' Consulting          Windows NT/Windows 95 software development
http://www.thebrads.com    Web site planning, development and maintenance





| Вернуться в корень Архива |