MFC CEdit scrollbar question
-
I constantly add more data into a CEdit, i also activated the scroll bar for this window. When the text exceeds the CEdit text area limit, the scroll bar is activated so i can scroll the text up and down which is good. Though instead of that i have to scroll downwards to see the new text added, is there a CEdit function which tells the scroll bar to always stay at max, or point downwards? So i have to scroll upwards instead to see the old text. Thanks
-
I constantly add more data into a CEdit, i also activated the scroll bar for this window. When the text exceeds the CEdit text area limit, the scroll bar is activated so i can scroll the text up and down which is good. Though instead of that i have to scroll downwards to see the new text added, is there a CEdit function which tells the scroll bar to always stay at max, or point downwards? So i have to scroll upwards instead to see the old text. Thanks
Hi Fredrick, I think there is no direct way. Though you could call something like this
CEdit myEdit;
CString csContent = _T("");
myEdit.GetWindowText( csContent );
myEdit.SetSel( csContent.GetLength(),
csContent.GetLength(),
TRUE /* scroll to the selected text */ );.. every time you add new text to your edit control.
Kind Regards, Robert Kuster _________________ www.it.rkuster.com
-
Hi Fredrick, I think there is no direct way. Though you could call something like this
CEdit myEdit;
CString csContent = _T("");
myEdit.GetWindowText( csContent );
myEdit.SetSel( csContent.GetLength(),
csContent.GetLength(),
TRUE /* scroll to the selected text */ );.. every time you add new text to your edit control.
Kind Regards, Robert Kuster _________________ www.it.rkuster.com
Hi Robert How do i focus it to the correct idc? i get an assert: { ASSERT(::IsWindow(m_hWnd)); ::SendMessage(m_hWnd, EM_SETSEL, nStartChar, nEndChar); if (!bNoScroll) this is the code i have: void CAutoUpdaterDlg::OnUpdateScreen() { char LocalBuffer[10]; itter++; sprintf(LocalBuffer, "%d", itter); CEdit * p = static_cast(GetDlgItem(IDC_Window)); // static message for now if(!FilesInProgress) { strcat(WindowBuffer, LocalBuffer); strcat(WindowBuffer, ": "); } else strcat(WindowBuffer, ""); strcat(WindowBuffer, DynamicBuffer); int Size = strlen(WindowBuffer); p->SetMargins(5,5); p->SetWindowText(Convert_A_To_DA(WindowBuffer)); CProgressCtrl * progress = static_cast(GetDlgItem(IDC_PROGRESS)); progress->SetRange(0,MaxRange);Progress++; progress->SetPos(Progress); int MemSize = strlen(DynamicBuffer); for(int i = 0; i<= MemSize+1; i++) { DynamicBuffer[i] = 0x00; } CEdit myEdit; CString csContent = _T(Convert_A_To_DA(WindowBuffer)); myEdit.GetWindowText( csContent ); myEdit.SetSel( csContent.GetLength(), csContent.GetLength(), TRUE /* scroll to the selected text */ ); UpdateWindow(); FilesInProgress = false; }