IPogressDialog
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: IPogressDialog

  1. #1
    Join Date
    Apr 1999
    Posts
    3,585

    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!

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,598

    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

  3. #3
    Join Date
    Apr 1999
    Posts
    3,585

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center