예제 #1
0
        // find the name of the base class for this HWND.  If this fails for any reason just return null.
        private static string GetBaseClassName(NativeMethods.HWND hwnd)
        {
            const int OBJID_QUERYCLASSNAMEIDX = unchecked (unchecked ((int)0xFFFFFFF4));
            const int QUERYCLASSNAME_BASE     = 65536;

            if (IsKnownBadWindow(hwnd))
            {
                return(RealGetWindowClass(hwnd).ToLower(CultureInfo.InvariantCulture));
            }

            IntPtr result = Misc.SendMessageTimeout(hwnd, UnsafeNativeMethods.WM_GETOBJECT, IntPtr.Zero, (IntPtr)OBJID_QUERYCLASSNAMEIDX);
            int    index  = (int)result;

            if (index >= QUERYCLASSNAME_BASE && index - QUERYCLASSNAME_BASE < _classNames.Length)
            {
                return(_classNames[index - QUERYCLASSNAME_BASE].ToLower(CultureInfo.InvariantCulture));
            }
            else
            {
                return(RealGetWindowClass(hwnd).ToLower(CultureInfo.InvariantCulture));
            }
        }
예제 #2
0
        // OnEventSystemCaptureStart - process an EventSystemCaptureStart WinEvent.
        private void OnEventSystemCaptureStart(int eventId, IntPtr hwnd, int idObject, int idChild, uint eventTime)
        {
            // Deal only with Combolbox dropdowns...
            if (Accessible.IsComboDropdown(hwnd))
            {
                // Need to get id of focused item...
                try
                {
                    IntPtr     i   = Misc.SendMessageTimeout(NativeMethods.HWND.Cast(hwnd), UnsafeNativeMethods.LB_GETCURSEL, IntPtr.Zero, IntPtr.Zero);
                    Accessible acc = Accessible.Create(hwnd, UnsafeNativeMethods.OBJID_CLIENT, i.ToInt32() + 1);
                    if (acc == null)
                    {
                        return;
                    }

                    HandleFocusChange(hwnd, acc, idObject, idChild, eventTime);
                }
                catch (TimeoutException)
                {
                    // Ignore
                }
            }
        }