Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

NJed

Technical User
Jul 13, 2005
11
SE
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:


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
 
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.
 
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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top