I am using an IProgressDialog object to reflect the progress during a long operation. Through experimentation, I've noticed that the Cancel button is not responsive if I pass a non-NULL handle as the parent to the progress dialog. And, if I try to move the dialog, it will not work. It doesn't matter if I use a marquee style or a stepped style. Here's some sample code...
Is this by design? Is this a bug? Am I redirecting the progress dialog messaging by providing a handle to a parent dialog? The only way I can get it to work correctly, is to pass a NULL handle.
October 11th, 2012, 08:10 AM
zerver
Re: IPogressDialog
Never used this specific UIProgressDialog, but I am guessing you have to manually pump the messages through when you have the parent specified. In this case you need to call a function like the one below from inside your loop.
Code:
void CMainFrame::DoEvents() {
MSG msg;
// Process existing messages in the application's message queue.
// When the queue is empty, do clean up and return.
while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE) && !g_bCancel)
{
if (!AfxGetThread()->PumpMessage())
return;
}
}
October 11th, 2012, 09:11 AM
Mike Harnad
Re: IPogressDialog
Thanks for the reply. However, I don't think your sample is applicable here. IProgressDialog creates a separate thread to do its work. And, there is no mention in the documentation that using a non-NULL handle for a parent requires handling the message processing differently.