Solved

indeterminate progress bars

Posted on 2002-07-19
9
638 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
Independent Software Vendors: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries FTP Exit Program 8 163
How to know only "File created" with EventLog 3 35
notReplace  challenge 53 151
x-bar in Google Sheets 2 93
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 …
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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