App modal dialog to display progress of some lengthy operation
Posted on 2003-03-06
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.