Click here to Skip to main content
15,920,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: help Pin
Rajesh R Subramanian27-Feb-07 6:25
professionalRajesh R Subramanian27-Feb-07 6:25 
QuestionMail Merge concept Pin
Anandan k27-Feb-07 3:20
Anandan k27-Feb-07 3:20 
AnswerRe: Mail Merge concept Pin
prithaa27-Feb-07 5:08
prithaa27-Feb-07 5:08 
AnswerRe: Mail Merge concept Pin
Hamid_RT27-Feb-07 7:40
Hamid_RT27-Feb-07 7:40 
QuestionAuto scroll to specific line in text box Pin
Jim Crafton27-Feb-07 3:16
Jim Crafton27-Feb-07 3:16 
AnswerRe: Auto scroll to specific line in text box Pin
KaЯl27-Feb-07 4:01
KaЯl27-Feb-07 4:01 
GeneralRe: Auto scroll to specific line in text box Pin
Jim Crafton27-Feb-07 4:32
Jim Crafton27-Feb-07 4:32 
GeneralRe: Auto scroll to specific line in text box Pin
KaЯl27-Feb-07 5:45
KaЯl27-Feb-07 5:45 
I made some tests and what I said was wrong, sorry. However, I may have found a way to do so based on the behavior of CRichCtrlEdit.
If you scroll to the end of a richedit, you will see that when you add text the richedit will scroll automatically. If the last line is 'below' the visible area, the richedit will not scroll.

A way to automate this is by using CRichEdit::LineScroll. The problem is to get the number of lines to scroll.
I tried this way:

<br />
	long iStart, iEnd;<br />
	m_RichEditCtrl.GetSel(iStart, iEnd);<br />
<br />
	int iIndex = m_RichEditCtrl.GetLineCount() - m_RichEditCtrl.GetFirstVisibleLine();<br />
	CDC *pDC = m_RichEditCtrl.GetDC();<br />
	CFont *pFont = m_RichEditCtrl.GetFont();<br />
	CFont *pOldFont = pDC->SelectObject(pFont);<br />
	CRect clientRect;<br />
<br />
	m_RichEditCtrl.GetClientRect(&clientRect);<br />
<br />
	TEXTMETRIC tm;<br />
	pDC->GetTextMetrics(&tm);<br />
	pDC->SelectObject(pOldFont);<br />
<br />
	int iCount  = (int)((double) clientRect.bottom / tm.tmHeight) + 1;<br />
<br />
	m_RichEditCtrl.LineScroll(iCount);<br />


And to put the last line 'below ' the richedit scope:
<br />
	m_RichEditCtrl.LineScroll(-1);<br />


It's not perfect, I didn't test all the cases, but it 'globally' works






Society is composed of two great classes, those that have more dinners than appetite, and those who have more appetite than dinners

Fold with us! ¤ flickr

QuestionProject release problem Pin
david bagaturia27-Feb-07 2:33
david bagaturia27-Feb-07 2:33 
AnswerRe: Project release problem Pin
toxcct27-Feb-07 2:46
toxcct27-Feb-07 2:46 
QuestionWM_RELEASEDCAPTURE(tab) Pin
RaviPK27-Feb-07 1:46
RaviPK27-Feb-07 1:46 
AnswerRe: WM_RELEASEDCAPTURE(tab) Pin
James R. Twine27-Feb-07 2:49
James R. Twine27-Feb-07 2:49 
GeneralRe: WM_RELEASEDCAPTURE(tab) Pin
RaviPK27-Feb-07 17:46
RaviPK27-Feb-07 17:46 
QuestionDatatypes - Urgent Pin
janadhana27-Feb-07 1:42
janadhana27-Feb-07 1:42 
JokeRe: Datatypes - Urgent Pin
James R. Twine27-Feb-07 2:45
James R. Twine27-Feb-07 2:45 
QuestionThread Question Pin
Programm3r27-Feb-07 1:01
Programm3r27-Feb-07 1:01 
AnswerRe: Thread Question Pin
James R. Twine27-Feb-07 1:16
James R. Twine27-Feb-07 1:16 
GeneralRe: Thread Question Pin
Programm3r27-Feb-07 1:25
Programm3r27-Feb-07 1:25 
AnswerRe: Thread Question Pin
Newbie0027-Feb-07 1:19
Newbie0027-Feb-07 1:19 
GeneralRe: Thread Question Pin
Programm3r27-Feb-07 1:27
Programm3r27-Feb-07 1:27 
AnswerRe: Thread Question Pin
Nibu babu thomas27-Feb-07 3:37
Nibu babu thomas27-Feb-07 3:37 
GeneralRe: Strange Font bolding Pin
super_ttd27-Feb-07 0:09
super_ttd27-Feb-07 0:09 
GeneralRe: Strange Font bolding Pin
Nibu babu thomas27-Feb-07 0:12
Nibu babu thomas27-Feb-07 0:12 
GeneralRe: Strange Font bolding Pin
super_ttd27-Feb-07 21:55
super_ttd27-Feb-07 21:55 
GeneralRe: Strange Font bolding Pin
Nibu babu thomas28-Feb-07 17:24
Nibu babu thomas28-Feb-07 17:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.