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 6874925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:15:22+00:00 2026-05-27T04:15:22+00:00

When using ATL, what is the best way to display the progress of a

  • 0

When using ATL, what is the best way to display the progress of a background thread (e.g. when it’s searching for a file) without blocking the UI?

I still want to be able to process messages, to allow for a Cancel button and to possibly allow the user to continue working with the program while the search happens.

  • 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. Editorial Team
    Editorial Team
    2026-05-27T04:15:23+00:00Added an answer on May 27, 2026 at 4:15 am

    There is no ATL specific here. One of the ways to do is to update progress details into member variable and post a message to GUI window, then handle the message by pulling the data from member variable and updating GUI, such as updating static and/or progress bar.

    Worker thread pseudo-code:

    m_DataCriticalSection.Lock();
    m_nProgress = (INT) (nCurrent * 100 / nTotal);
    m_DataCriticalSection.Unlock();
    PostMessage(WM_MYUPDATEPROGRESS);
    

    Window:

    OnMyUpdateProgress()
    {
      m_DataCriticalSection.Lock();
      INT nProgress = m_nProgress;
      m_DataCriticalSection.Unlock();
      m_ProgressBar.SetPos(nProgress);
    }
    

    UPD. A real code snippet, AddText is called on background thread, :

        VOID AddText(const CString& sText)
        {
                _A(sText.Find(_T('\n')) < 0);
                BOOL bIsTextEmpty;
                {
                        CRoCriticalSectionLock TextLock(m_TextCriticalSection);
                        bIsTextEmpty = m_sText.IsEmpty();
                        m_sText.Append(sText);
                        m_sText.Append(_T("\r\n"));
                }
                if(bIsTextEmpty)
                        PostPrivateMessage(WM_UPDATETEXT);
        }
    

    And the code handler:

    BEGIN_MSG_MAP_EX(CMainDialog)
            // ...
            MESSAGE_HANDLER_EX(WM_UPDATETEXT, OnUpdateText)
    
        LRESULT OnUpdateText(UINT, WPARAM, LPARAM)
        {
                CString sText;
                {
                        CRoCriticalSectionLock TextLock(m_TextCriticalSection);
                        sText = m_sText;
                        m_sText.Empty();
                }
                if(!sText.IsEmpty())
                {
                        m_TextEdit.SetValue(m_TextEdit.GetValue() + sText);
                        const INT nTextLength = m_TextEdit.GetWindowTextLength();
                        m_TextEdit.SetSel(nTextLength, nTextLength);
                }
                return 0;
        }
    

    This uses custom classes (not ‘pure’ ATL), but I hope you get the idea.

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

Sidebar

Related Questions

Using a CDialogImpl derived class as a dialog-based WTL/ATL app, I want to hide
I created a ActiveX control using ATL, already package it with signature. I want
In my free-threaded in-proc COM object using ATL I want to add a member
I want to parse this content using Javascript. The data looks like this: {ss:[[Thu,7:00,Final,,BAL,19,ATL,20,,,56808,,PRE4,2015],[Thu,7:00,Final,,NO,10,GB,38,,,56809,,PRE4,2015]]}
Without : MFC ATL using COM , with pure C++ , steps taken thus
I created a dll file built (Project:win32 app, ATL and COM object using Visual
Without: MFC ATL Using pure C++, WSAGetLastError() returns 10014 - Bad address What I'm
Is there some kind of tool for creating user interfaces using ATL for C/C++?
I have a COM outproc server written in ATL that registers itself using _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER,
I'm maintaining an MFC/COM/ATL 45-odd project solution originally written with VS6. I'm now using

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.