public void Close() { Window dialog = new Window(hwnd); if (dialog.Visible) { dialog.ForceClose(); } }
/// <summary> /// If the window is a dialog and visible, it will be passed to /// the registered dialog handlers. I none if these can handle /// it, it will be closed if <see cref="CloseUnhandledDialogs"/> /// is <c>true</c>. /// </summary> /// <param name="window">The window.</param> public void HandleWindow(Window window) { if (window.IsDialog()) { // Wait untill window is visible so all properties // of the window class (like Style and StyleInHex) // will return valid values. while (window.Visible == false) { Thread.Sleep(50); } // Lock the thread and see if a handler will handle // this dialog window lock (this) { foreach (IDialogHandler dialogHandler in handlers) { try { if (dialogHandler.HandleDialog(window)) { return; } } catch (Exception e) { lastException = e; } } // If no handler handled the dialog, see if it // should be close automatically. if (CloseUnhandledDialogs && !PopupDialog.IsWarningPopup(window.Hwnd, InfoPathWarningStyleInHex)) { window.ForceClose(); } } } }