Skip to content

Instantly share code, notes, and snippets.

@jimevans
Created October 4, 2011 15:39
Show Gist options
  • Save jimevans/1261966 to your computer and use it in GitHub Desktop.
Save jimevans/1261966 to your computer and use it in GitHub Desktop.
bool HtmlDialog::Wait() {
// If the window handle is no longer valid, the window is closing,
// the wait is completed, and we must post the quit message.
if (!::IsWindow(this->GetTopLevelWindowHandle())) {
this->is_navigating_ = false;
this->set_is_closing(true);
this->PostQuitMessage();
return true;
}
// If we're not navigating to a new location, we should check to see if
// a new modal dialog has been opened. If one has, the wait is complete,
// so we must set the flag indicating to the message loop not to call wait
// anymore.
if (!this->is_navigating_) {
HWND child_dialog_handle = this->GetActiveDialogWindowHandle();
if (child_dialog_handle != NULL) {
HWND content_window_handle = this->FindContentWindowHandle(child_dialog_handle);
// This if statement is the difference from the existing code.
// If the content window handle is NULL, then maybe it
// hasn't had the chance to be created yet, so don't post
// the message, and continue to wait.
if (content_window_handle != NULL) {
::Sleep(500);
::PostMessage(this->executor_handle(),
WD_NEW_HTML_DIALOG,
NULL,
reinterpret_cast<LPARAM>(content_window_handle));
this->set_wait_required(false);
return true;
}
}
}
// Otherwise, we wait until navigation is complete.
::Sleep(250);
return !this->is_navigating_;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment