Solved

indeterminate progress bars

Posted on 2002-07-19
9
652 Views
Last Modified: 2013-11-20
Hi ,
 Does anyone know on how to create indeterminate progress bars in a dialog. I have this big dialog function which will load another DLL and execute functions within it. I need to show in my dialog that a processing is going on. I tried creating a thread and updating the progress control but no luck. It looks like the message pump is blocked until the dialog function is completed. Is there any other way I could implement this

Thanks
Saravana
0
Comment
Question by:vsaravana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
9 Comments
 
LVL 8

Expert Comment

by:fl0yd
ID: 7166105
Using multi-threading is the way to go. I don't know what you did, but you must have made a mistake. Did you create the thread to do the actual work? I assume you created a thread to do the updating of the progress bar. In that case the dialog message-handler isn't called until the function doing the calculations has returned.
0
 

Author Comment

by:vsaravana
ID: 7166835
You are correct, I did create the thread for the progress update. It's difficult as per the previous implementation to move tons of code into a thread.
Is there any other option..??

0
 
LVL 8

Accepted Solution

by:
fl0yd earned 100 total points
ID: 7166939
You could use a CWinThread-function (PumpMessage) that is not really well documented:

void DoEvents() {

    MSG msg = { 0 };
    HWND hwnd = AfxGetMainWnd->m_hWnd;
    while( ::PeekMessage( &msg, hwnd, 0, 0, PM_NOREMOVE ) )
        AfxGetApp()->PumpMessage();
}

Call this function whenever you need to respond to messages. So your code would look like this:

void ThisFunctionTakesForEver() {

    // do some code here
    DoEvents();
    // do some more code...
    DoEvents();
    // and so on...
}

If you use this you won't have to use multithread, which is a very complex field of programming.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Expert Comment

by:fl0yd
ID: 7166942
ooooops, there was a mistake. The right way to go:

    HWND hwnd = AfxGetMainWnd()->m_hWnd;
0
 
LVL 1

Expert Comment

by:jemax
ID: 7167769
Hi,

you could use CWnd::UpdateWindow it bypasses message queue, so your progress bar will be updated.

HTH,
jemax
0
 
LVL 8

Expert Comment

by:fl0yd
ID: 7167803
UpdateWindow sends a WM_PAINT message if the update region isn't empty -- what good is it if those aren't handled?
0
 
LVL 1

Expert Comment

by:jemax
ID: 7168847
Hi,

forgive me, my stupid comment. I forgot that is not possible to SendMessage into wnd thread from another thread, it would cause to deadlock.

Sorry.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question