Solved

indeterminate progress bars

Posted on 2002-07-19
9
644 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ODBC Connection Logging, ADO.NET 6 73
no14 challenge 14 77
"Black Box" Testing of Control System Software 2 125
Windows shortcut location resolution on double click open 4 77
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 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