Пример #1
0
        bool ClickCancelCB()
        {
            IntPtr cancel_btn = Win32.GetDlgItem(hWnd, CancelButton);

            Win32.PostMessage(cancel_btn, Win32.BM_CLICK, (IntPtr)0, IntPtr.Zero);
            return(true);
        }
Пример #2
0
        bool ClickOpenSaveButtonCB()
        {
            IntPtr open_btn = Win32.GetDlgItem(hWnd, OpenButton);

            Win32.PostMessage(open_btn, Win32.BM_CLICK, (IntPtr)0, IntPtr.Zero);
            return(true);
        }
Пример #3
0
        ///<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());
        }
Пример #4
0
        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("XunitForms 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);
        }