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. [Q] Updating an control inside other control handler problem...

[Q] Updating an control inside other control handler problem...

Scheduled Pinned Locked Moved C / C++ / MFC
comtoolshelptutorialquestion
1 Posts 1 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.
  • R Offline
    R Offline
    rbid
    wrote on last edited by
    #1

    Hello, Setting the edit box text via SetWindowText does not work inmediatelly if you set it from one of the handlers of your dialog. Instead, the update will happen only after the handler ends its run.

    void CDemoDlg::OnNewBnClicked()
    {
    m_newBtn.EnableWindow(FALSE);
    GetDlgItem(IDC_STATUS_EDIT)->SetWindowText("New"); // Change here to IDC_STATUS_STATIC
    ...
    // Some code that takes few msec to end
    ...
    m_newBtn.EnableWindow(TRUE);
    }

    If I replace the Edit Control with a static control, the text is updated inmediatelly. (Before the button control is enabled) I guess that the answer is the use of SendMessage and PostMessage. Is there a way to update an edit control inmediatelly and not wait till the handler ends? Any hint? (I need an edit control there) Another example:

    void CDemoDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
    {
    HWND hwnd = pScrollBar->GetSafeHwnd();
    if (hwnd == m_mainCursorSliderCtrl.GetSafeHwnd())
    {
    int pos = m_mainCursorSliderCtrl.GetPos();
    if (pos != m_mainCursorPosition)
    {
    CString text;
    m_mainCursorPosition = pos;
    text.Format("Main:%d", pos)
    GetDlgItem(IDC_STATUS_EDIT)->SetWindowText(text);
    GetDlgItem(IDC_STATUS_STATIC)->SetWindowText(text);
    UpdateListControlData();
    }
    }

    }
    
    CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
    

    }

    The list control and IDC_STATUS_EDIT is update only when the slider-bar stops, while the IDC_STATUS_STATIC is updated on real-time. -- **Ricky Marek** (_AKA: rbid_) -- "Things are only impossible until they are not" --- Jean-Luc Picard My articles

    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