-
September 19th, 2012, 08:42 AM
#1
IPogressDialog
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...
Code:
UIProgressDialog ProgressDlg;
ProgressDlg.Init ();
ProgressDlg.SetTitle (_T("Sample Title"));
//xxxProgressDlg.StartProgressDialog (m_hWnd, UIProgressStyle::UIPS_Marquee);
ProgressDlg.StartProgressDialog (m_hWnd);
ProgressDlg.SetCancelMessage (_T("Cancelling..."));
ProgressDlg.SetLineText (1, _T("Line 1 of text"), FALSE);
ProgressDlg.SetLineText (2, _T("Line 2 of text"), FALSE);
ProgressDlg.SetLineText (3, _T("Line 3 of text"), FALSE);
for (int i=0; i<1000; i++)
{
CString msg;
if (ProgressDlg.HasUserCancelled()) break;
msg.Format ("I'm processing item %d", i);
ProgressDlg.SetLineText (2, msg, FALSE);
Sleep(50);
ProgressDlg.SetProgress(i, 1000);
}
ProgressDlg.StopProgressDialog ();
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.
Gort...Klaatu, Barada Nikto!
-
October 11th, 2012, 08:10 AM
#2
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;
}
}
Nobody cares how it works as long as it works
-
October 11th, 2012, 09:11 AM
#3
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.
Gort...Klaatu, Barada Nikto!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|