示例#1
0
 public static System.IntPtr FindWindowByPosition(System.IntPtr hWndParent, int processId, int threadId, int x, int y, bool ignoreProcThread)
 {
     _CurrWindowComparer = delegate(System.IntPtr hWnd) {
         LPPOINT lpPoint = new LPPOINT();
         LPRECT  lpRect  = new LPRECT();
         Win32NativeMethods.GetWindowRect(hWnd, ref lpRect);
         lpPoint.X = lpRect.Left;
         lpPoint.Y = lpRect.Top;
         Win32NativeMethods.ScreenToClient(hWndParent, ref lpPoint);
         return((bool)(((ignoreProcThread || IsHwndOnProcThread(hWnd, processId, threadId)) && ((int)lpPoint.X).Equals(x)) && ((int)lpPoint.Y).Equals(y)));
     };
     return(FindWindowViaBfs(hWndParent));
 }
示例#2
0
 internal static bool IsCheckBoxStateReadable(System.IntPtr hWnd)
 {
     switch ((Win32NativeMethods.GetWindowLong(hWnd, WinUserConstant.GWL_STYLE) & ((uint)15)))
     {
     case 2:
     case 3:
     case 4:
     case 5:
     case 6:
     case 9:
         return(true);
     }
     return(false);
 }
示例#3
0
        internal static void SelectNextComboBoxItem(System.IntPtr hWnd)
        {
            int num = (int)Win32NativeMethods.SendMessage(hWnd, ComboBoxMessage.CB_GETCOUNT, System.IntPtr.Zero, System.IntPtr.Zero);

            if (num > 0)
            {
                int index = (int)Win32NativeMethods.SendMessage(hWnd, ComboBoxMessage.CB_GETCURSEL, System.IntPtr.Zero, System.IntPtr.Zero);
                if (index >= -1)
                {
                    index = (int)((index + 1) % num);
                    SelectComboBoxItem(hWnd, index);
                }
            }
        }
示例#4
0
        internal static string GetCheck(System.IntPtr hWnd)
        {
            if (IsCheckBoxStateReadable(hWnd))
            {
                switch (((int)Win32NativeMethods.SendMessage(hWnd, ButtonControlMessage.BM_GETCHECK, System.IntPtr.Zero, System.IntPtr.Zero)))
                {
                case 0:
                    return(bool.FalseString);

                case 1:
                    return(bool.TrueString);
                }
                return("indeterminate");
            }
            return("unreadable");
        }
示例#5
0
 internal static void SetCheck(System.IntPtr hWnd, string checkStateStr)
 {
     if (!IsWindowDisabled(hWnd))
     {
         bool flag;
         ButtonControlMessage message;
         if (bool.TryParse(checkStateStr, out flag))
         {
             message = flag ? ButtonControlMessage.BST_CHECKED : ButtonControlMessage.BST_UNCHECKED;
         }
         else
         {
             message = ButtonControlMessage.BST_INDETERMINATE;
         }
         Win32NativeMethods.SendMessage(hWnd, ButtonControlMessage.BM_SETCHECK, (System.IntPtr)((long)message), System.IntPtr.Zero);
     }
 }
示例#6
0
        private static System.IntPtr FindWindowViaBfs(System.IntPtr hWndRoot)
        {
            System.IntPtr         zero  = System.IntPtr.Zero;
            Queue <System.IntPtr> queue = new Queue <System.IntPtr>();

            queue.Enqueue(hWndRoot);
            while (!((int)queue.Count).Equals(0) && zero.Equals((System.IntPtr)System.IntPtr.Zero))
            {
                for (System.IntPtr ptr2 = queue.Dequeue(); !ptr2.Equals((System.IntPtr)System.IntPtr.Zero); ptr2 = Win32NativeMethods.GetWindow(ptr2, WinUserConstant.SW_SHOWMINIMIZED))
                {
                    if (_CurrWindowComparer(ptr2))
                    {
                        zero = ptr2;
                        continue;
                    }
                    System.IntPtr window = Win32NativeMethods.GetWindow(ptr2, WinUserConstant.SW_SHOW);
                    if (!window.Equals((System.IntPtr)System.IntPtr.Zero))
                    {
                        queue.Enqueue(window);
                    }
                }
            }
            return(zero);
        }
示例#7
0
 public static System.IntPtr FindWindowByControlId(System.IntPtr hWndParent, int processId, int threadId, int controlId, int matchCount, bool ignoreProcThread)
 {
     _CurrWindowComparer = hWnd => (bool)(((ignoreProcThread || IsHwndOnProcThread(hWnd, processId, threadId)) && ((Win32NativeMethods.GetDlgCtrlID(hWnd) == controlId) && (ignoreProcThread || IsHwndOnProcThread(hWnd, processId, threadId)))) && ((bool)((matchCount = (int)(matchCount - 1)) <= 0)));
     return(FindWindowViaBfs(hWndParent));
 }
示例#8
0
 internal static void SelectMenuItem(System.IntPtr hWnd, int hMenuItemId)
 {
     Win32NativeMethods.PostMessage(hWnd, WindowMessage.WM_COMMAND, (System.IntPtr)hMenuItemId, System.IntPtr.Zero);
 }
示例#9
0
 internal static bool IsWindowDisabled(System.IntPtr hWnd)
 {
     return((bool)((Win32NativeMethods.GetWindowLong(hWnd, WinUserConstant.GWL_STYLE) & 0x8000000) == 0x8000000));
 }
示例#10
0
 internal static bool IsWindow(System.IntPtr hWnd)
 {
     return(!((int)Win32NativeMethods.IsWindow(hWnd)).Equals((System.IntPtr)System.IntPtr.Zero));
 }
示例#11
0
 internal static string GetWindowTextAny(System.IntPtr hWnd)
 {
     System.Text.StringBuilder lParam = new System.Text.StringBuilder(0x80);
     Win32NativeMethods.SendMessage(hWnd, WindowMessage.WM_GETTEXT, (System.IntPtr)lParam.Capacity, lParam);
     return(lParam.ToString());
 }
示例#12
0
 internal static string GetWindowText(System.IntPtr hWnd)
 {
     System.Text.StringBuilder lpString = new System.Text.StringBuilder(0x80);
     Win32NativeMethods.GetWindowText(hWnd, lpString, lpString.Capacity);
     return(lpString.ToString());
 }
示例#13
0
 internal static string GetWindowClass(System.IntPtr hWnd)
 {
     System.Text.StringBuilder lpClassName = new System.Text.StringBuilder(0x80);
     Win32NativeMethods.GetClassName(hWnd, lpClassName, lpClassName.Capacity);
     return(lpClassName.ToString());
 }
示例#14
0
 internal static string GetMenuString(System.IntPtr hMenu, int subMenuIndex)
 {
     System.Text.StringBuilder lpString = new System.Text.StringBuilder(0x80);
     Win32NativeMethods.GetMenuString(hMenu, (uint)subMenuIndex, lpString, lpString.Capacity, WinUserConstant.MF_BYPOSITION);
     return(lpString.ToString());
 }