App modal dialog to display progress of some lengthy operation

Posted on 2003-03-06
Medium Priority
Last Modified: 2013-11-20
Hello experts.

This question has been asked several times in different variations in this forum, but none of the answers suits my scenario.  I hope to get an answer that does.

In a standard MFC command message handler, I call a FuncA), that starts doing some file analysis.  This may take very long time, so I need a dialog box with a progress control to report on how this function is doing.  

Here are the constraints of the problem:

FuncA() resides in a remote DLL.  It must run in the same thread as the MMI that calls it, so I cannot accept answers that suggest splitting threads.

The App modal dialog, AppDlg, should be displayed as
Funca() begins its work. From what I understand, it cannot be a modal dialog, but modeless (so it won't steal the message loop), but please correct me if I am wrong.

AppDlg has a Cancel button, that when clicked, should cause FuncA to abort its operation

FuncA which runs in a loop should post a message to the dialog with progress indication every iteration.

I tried something like

while ( PeekMessage( &msg, NULL, NULL, NULL, PM_REMOVE  ) )
DispatchMessage( &msg );

in FuncA(), and this is probably the right direction, but I couldn’t see messages, other than mouse messages(???).  Also, the main application window should not get command messages(But should get WM_PAINT).

Well I hope my modest question gets you attention and your valueable time.
Question by:trabar
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
LVL 30

Accepted Solution

SteveGTR earned 800 total points
ID: 8088508
LVL 49

Expert Comment

ID: 8094828
What I do is create a Modeless dialog and put all of the processing inside of that dialog class.  When a Modeless dialog is active, bot it and its parent window continue to receive and handle messages normally.

One normally needs to take some special actions in the parent window, such as disabling certain menu items or providing other U/I clues to prevent (for instance) the user from starting a second instance of that task.

The other option (which you have rejected) is to split off a secondary thread and run a Modal dialog in that thread.

-- Dan

Author Comment

ID: 8097130
Thanks a lot - just what we needed

Featured Post

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!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

762 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