×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Waiting for a non-modal dialog box to appear before proceeding (Win32)

Waiting for a non-modal dialog box to appear before proceeding (Win32)

Waiting for a non-modal dialog box to appear before proceeding (Win32)

(OP)
I'm writing an application that draws a non-model dialog box which contains various controls to show percentage of progress complete, processing output, etc.

The call to create the dialog is nice and simple:

void MyClass::StartProgressBar()
{
    m_pProgressHWND = CreateDialog ( hInstance, MAKEINTRESOURCE ( IDD_PROGRESS ), m_pInterface->GetHWnd(), ProgressDlgProc );
    ShowWindow ( m_pProgressHWND, SW_SHOWNORMAL );
}

Nothing too strenuous and all is good.

The ProgressDlgProc callback is all set-up and captures WM_INITDIALOG and a few other messages and executes fine.

Now, the problem is I havea few helper functions to update various controls (text, progress bars) and they work fine and update the controls when called.

However, the problem is that the actually dialog doesn't actually finish it's main drawing until *after* the whole process is complete. Whats happening is the dialog frame is appearing, the controls that I update get updated but general stuff like group frames aren't drawn until the whole shebang is finished.

I did find this article via Google that does something similar but it's only to pause opening another dialog, not to pause the main process:

http://blogs.msdn.com/oldnewthing/archive/2006/09/25/770536.aspx

In simple terms what I want is something like:

StartProgressBar();
// do something here to wait until the dialog is fully drawn
DoProcess();

I've tried setting flags in the callback and looping in place until their state changes but of course, that locks my program into an endless loop.

Any insights?

- Jed

RE: Waiting for a non-modal dialog box to appear before proceeding (Win32)

Looks like you have a sequencing problem.

Have a look at WaitForMultipleObjects.  When each process finishes, it posts an event to the main waiting object.  When the main waiting object has received the appropriate number of events, it is ready to go.

RE: Waiting for a non-modal dialog box to appear before proceeding (Win32)

(OP)
Thanks. I'll check that out.

Actually, I discovered by accident when added some code later on that calling UpdateWindow() with the hWnd of the dialog actually re-draws the whole thing.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close