Auto Scroll for my Log edit..

Hello friends,
in VS 2005 VC++ MFC , a dlg based application is created.
The Main Dialog box has a large edit box called Log.
in the main Dialog, there is a menu bar that brings up other dialogbox via DoModal. After the dialogboxes are closed, log information is displaying in the edit box based on the users menu selection and dialog box operations...

I am able to display text in Multiline in the Edit box.. After few lines, scrollbars appear at the side and i am able to scroll down to see the latest added text at the botton.

What I want is as the text is added on the bottom of this edit box, i want the text to be scrolled up so that the new text is always displayed

Googling I found some tips and tried the following...
Setting the Edit Box properties AutoScroll to Yes etc.

Adding event Handlers to the text box like on Change and On Update.
I tried to display an AfxMessage box in these functions to see if the program gets into these functions after the text is added > It doesnt even get into these functions.

then I tried the following..

locrunLog->SetWindowTextW(RunLogEdit);
int ln = ((CEdit*)GetDlgItem(IDC_RUNLOG_EDIT))->GetWindowTextLength()-1;
((CEdit*)GetDlgItem(IDC_RUNLOG_EDIT))->SetScrollPos(ln);

But of No avail...

I looked at the properties window and he has placed an edit control itself and not Rich Edit Control.

Please help...
[1479 byte] By [softmessager] at [2007-11-20 11:18:50]
# 1 Re: Auto Scroll for my Log edit..
1. Get rid of GetDlgItem. Create the control member variable (say, c_LogEdit) for your "Log" edit control and use it instead!
2.c_LogEdit.SetWindowText(strSomeNewText);
c_LogEdit.LineScroll(c_LogEdit.GetLineCount(), 0);
VictorN at 2007-11-10 22:25:52 >
# 2 Re: Auto Scroll for my Log edit..
Tried the following
int ln = m_edRunLog.GetLineCount();
m_edRunLog.LineScroll(ln ,0);
UpdateWindow();

it doesnt scroll... although the value of ln is correct... its not scrolling
softmessager at 2007-11-10 22:26:52 >
# 3 Re: Auto Scroll for my Log edit..
1. The code I have posted does work for me. :cool:
2. I did Not set "Auto VScroll" style to "Yes", I set "Vertical Scroll" instead (and "Multiline", of course).

PS. And I don't know what is the purpose of UpdateWindow call in your case.
VictorN at 2007-11-10 22:28:01 >
# 4 Re: Auto Scroll for my Log edit..
Friends Finally I solved it

Thanks VictorN for the line...
m_edRunLog.LineScroll(m_edRunLog.GetLineCount(),0);

I tried to add it to my function but it wouldnt scroll..
Finally I added it to the OnPaint() funciton of my dialog.
...
...
...
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
m_edRunLog.LineScroll(m_edRunLog.GetLineCount(),0);
}
}

I dont know if this is the right method, but it works and the control is getting redrawn properly..

Thanks forum..
softmessager at 2007-11-10 22:29:02 >
# 5 Re: Auto Scroll for my Log edit..
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
m_edRunLog.LineScroll(m_edRunLog.GetLineCount(),0);
}
}
technoroj at 2007-11-10 22:30:05 >
# 6 Re: Auto Scroll for my Log edit..
Friends Finally I solved it
I tried to add it to my function but it wouldnt scroll..
Finally I added it to the OnPaint() funciton of my dialog.
...
I dont know if this is the right method, but it works and the control is getting redrawn properly..
I cannot call this "the right method". :cool:
And it sounds that the design of your dialog is not correct.
VictorN at 2007-11-10 22:31:04 >