Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 93609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:22:16+00:00 2026-05-10T23:22:16+00:00

I have a dialog in MFC with a CStatusBar. In a separate thread, I

  • 0

I have a dialog in MFC with a CStatusBar. In a separate thread, I want to change the pane text of status bar. However MFC complains with asserts? How is it done? An example code would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T23:22:17+00:00Added an answer on May 10, 2026 at 11:22 pm

    You could post a private message to the main frame window and ‘ask’ it to update the status bar. The thread would need the main window handle (don’t use the CWnd object as it won’t be thread safe). Here is some sample code:

    static UINT CMainFrame::UpdateStatusBarProc(LPVOID pParam);  void CMainFrame::OnCreateTestThread() {     // Create the thread and pass the window handle     AfxBeginThread(UpdateStatusBarProc, m_hWnd); }  LRESULT CMainFrame::OnUser(WPARAM wParam, LPARAM) {     // Load string and update status bar     CString str;     VERIFY(str.LoadString(wParam));     m_wndStatusBar.SetPaneText(0, str);     return 0; }  // Thread proc UINT CMainFrame::UpdateStatusBarProc(LPVOID pParam) {     const HWND hMainFrame = reinterpret_cast<HWND>(pParam);     ASSERT(hMainFrame != NULL);     ::PostMessage(hMainFrame, WM_USER, IDS_STATUS_STRING);     return 0; } 

    The code is from memory as I don’t have access to compiler here at home, so apologies now for any errors.

    Instead of using WM_USER you could register your own Windows message:

    UINT WM_MY_MESSAGE = ::RegisterWindowsMessage(_T('WM_MY_MESSAGE')); 

    Make the above a static member of CMainFrame for example.

    If using string resources is too basic then have the thread allocate the string on the heap and make sure the CMainFrame update function deletes it, e.g.:

    // Thread proc UINT CMainFrame::UpdateStatusBarProc(LPVOID pParam) {     const HWND hMainFrame = reinterpret_cast<HWND>(pParam);     ASSERT(hMainFrame != NULL);     CString* pString = new CString;     *pString = _T('Hello, world!');     ::PostMessage(hMainFrame, WM_USER, 0, reinterpret_cast<LPARAM>(pString));     return 0; }  LRESULT CMainFrame::OnUser(WPARAM, LPARAM lParam) {     CString* pString = reinterpret_cast<CString*>(lParam);     ASSERT(pString != NULL);     m_wndStatusBar.SetPaneText(0, *pString);     delete pString;     return 0; } 

    Not perfect, but it’s a start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a MFC dialog with 32 CComboBoxes on it that all have the
I have a dialog based MFC application through which I have to call a
I have a MFC dialog in Visual C++ 2005, (MFC Application) and I have
I have an MFC dialog in which there are two radio buttons. I have
I have an MFC dialog containing a dozen or so buttons, radio buttons and
I have a MFC dialog based application in which I use ::system() function to
I have a VC++ MFC dialog application and in my OnTimer function I am
Keyboard Enter key not working in MFC Dialog Box ? I have one MFC
I have a modal dialog I'm creating with MFC. When it appears, the Aero
I have a dialog-based MFC C++ app. My dialog displays a number of pages

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.