/// <summary> /// Finds the OpenFileDialog. /// </summary> protected static IntPtr FindFileDialog() { IntPtr desktop = Win32.GetDesktopWindow(); IntPtr res = IntPtr.Zero; Win32.EnumChildWindows(desktop, delegate(IntPtr hwnd, IntPtr lParam) { if (WindowHandle.IsDialog(hwnd)) { string name = WindowHandle.GetCaption(hwnd); if (name == FileDialogTester.InitialFileDialogName // Vista 64 hack || name == "Save as" || name == "Enregistrer sous" || name == "Speichern unter") { res = hwnd; } } return(1); }, IntPtr.Zero); if (res == IntPtr.Zero) { throw new ControlNotVisibleException("Open File Dialog is not visible"); } return(res); }
/// <summary> /// Finds all of the forms with a specified name and returns them in a FormCollection. /// </summary> /// <param name="formName">The name of the form to search for.</param> /// <returns>the FormCollection of all found forms.</returns> public List <Form> FindAll(string formName) { lock (this) { forms = new List <Form>(); name = formName; IntPtr desktop = Win32.GetDesktopWindow(); Win32.EnumChildWindows(desktop, FindMatchingForms, IntPtr.Zero); return(forms); } }