bool SetFileNameCB(string file) { if (!Win32.IsWindowVisible(hWnd)) { return(false); } IntPtr fnh = Win32.GetDlgItem(hWnd, FileNameCheckBox); if (fnh == IntPtr.Zero) { // On Vista 64, it seems the combo box does not have an id. However, it contains a control with id 1001. Win32.EnumChildWindows(hWnd, delegate(IntPtr wnd, IntPtr lparam) { if (Win32.GetDlgItem(wnd, 1001) == IntPtr.Zero) { return(1); } fnh = wnd; return(0); }, IntPtr.Zero); if (fnh == IntPtr.Zero) { throw new System.Exception("NUnitForms fatal error: cannot find filename box"); } Util.GetMessageHook.Record(delegate() { Win32.SetWindowText(fnh, file); StringBuilder sb = new StringBuilder(file.Length + 1); Win32.GetWindowText(fnh, sb, file.Length + 1); if (sb.ToString().ToLowerInvariant() != file.ToString().ToLowerInvariant()) { return(false); } IntPtr open_btn = Win32.GetDlgItem(hWnd, OpenButton); Win32.PostMessage(open_btn, Win32.BM_CLICK, (IntPtr)0, IntPtr.Zero); return(true); }); } else { Win32.SetDlgItemText(hWnd, FileNameCheckBox, file); StringBuilder sb = new StringBuilder(file.Length + 1); Win32.GetDlgItemText(hWnd, FileNameCheckBox, sb, file.Length + 1); if (sb.ToString().ToLowerInvariant() != file.ToString().ToLowerInvariant()) { return(false); } IntPtr open_btn = Win32.GetDlgItem(hWnd, OpenButton); Win32.PostMessage(open_btn, Win32.BM_CLICK, (IntPtr)0, IntPtr.Zero); return(true); } return(true); }