Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MFC CEdit scrollbar question

MFC CEdit scrollbar question

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FredrickNorge
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • F FredrickNorge

      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

      R Offline
      R Offline
      Robert Kuster
      wrote on last edited by
      #2

      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

      F 1 Reply Last reply
      0
      • R Robert Kuster

        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

        F Offline
        F Offline
        FredrickNorge
        wrote on last edited by
        #3

        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; }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups