/// <summary> /// Simulates that the open button is pressed. /// </summary> protected void ClickOpenSaveOpen() { IntPtr box = FindFileDialog(); IntPtr open_btn = Win32.GetDlgItem(box, OpenButton); Win32.PostMessage(open_btn, (uint)Win32.BM_CLICK, (IntPtr)0, IntPtr.Zero); }
/// <summary> /// Clicks the cancel button of a OpenFiledialog. /// </summary> public void ClickCancelHandler() { IntPtr box = FindFileDialog(); IntPtr cancel_btn = Win32.GetDlgItem(box, CancelButton); Win32.PostMessage(cancel_btn, (uint)Win32.BM_CLICK, (IntPtr)0, IntPtr.Zero); }
bool ClickCancelCB() { IntPtr cancel_btn = Win32.GetDlgItem(hWnd, CancelButton); Win32.PostMessage(cancel_btn, Win32.BM_CLICK, (IntPtr)0, IntPtr.Zero); return(true); }
bool ClickOpenSaveButtonCB() { IntPtr open_btn = Win32.GetDlgItem(hWnd, OpenButton); Win32.PostMessage(open_btn, Win32.BM_CLICK, (IntPtr)0, IntPtr.Zero); return(true); }
///<summary> /// Returns the text of the references control. ///</summary> ///<param name="handle">A window handle to a control.</param> ///<returns>The text of the control.</returns> public static string GetText(IntPtr handle) { IntPtr handleToDialogText = Win32.GetDlgItem(handle, 0xFFFF); StringBuilder buffer = new StringBuilder(255); Win32.GetWindowText(handleToDialogText, buffer, 255); return(buffer.ToString()); }
/// <summary> /// Sets the filename in the filename ComboBox and presses the OpenSave button. /// </summary> /// <param name="file_name"></param> protected void SetFileName(string file_name) { IntPtr box = FindFileDialog(); Win32.SetDlgItemText(box, FileNameCheckBox, file_name); IntPtr open_btn = Win32.GetDlgItem(box, OpenButton); Win32.PostMessage(open_btn, (uint)Win32.BM_CLICK, (IntPtr)0, IntPtr.Zero); }
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); }