[Mwinapi-commits] SF.net SVN: mwinapi:[113] trunk/ManagedWinapi
Status: Beta
Brought to you by:
schierlm
|
From: <po...@us...> - 2012-07-01 16:06:28
|
Revision: 113
http://mwinapi.svn.sourceforge.net/mwinapi/?rev=113&view=rev
Author: poovenb
Date: 2012-07-01 16:06:19 +0000 (Sun, 01 Jul 2012)
Log Message:
-----------
(1) Created new folders to organise namespaces: moved files accordingly.
(2) Added TextCursor and TextCursorProvider that allow a custom caret to be used. However, this only seems to work well for TextBox Control types. The aim was to ensure that the user selected color is used: by default the Windows API applies a bit mask so that the displayed color will not match the user elected color for non-white backgrounds.
(3) Added BitmapDataHandler and PixelData that provide fast bitmap modification for large bitmap operations.
(4) It seems that Screenshot was not added to the project; Visual Studio 2010 has included it.
Modified Paths:
--------------
trunk/ManagedWinapi/ManagedWinapi.csproj
Added Paths:
-----------
trunk/ManagedWinapi/Accessibility/
trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs
trunk/ManagedWinapi/Accessibility/SystemAccessibleObject.cs
trunk/ManagedWinapi/Audio/
trunk/ManagedWinapi/Audio/Mixer/
trunk/ManagedWinapi/Audio/Mixer/Mixer.cs
trunk/ManagedWinapi/Audio/Mixer/MixerControl.cs
trunk/ManagedWinapi/Audio/Mixer/MixerLine.cs
trunk/ManagedWinapi/BitmapDataHandler.cs
trunk/ManagedWinapi/Hooks/
trunk/ManagedWinapi/Hooks/Hook.cs
trunk/ManagedWinapi/Hooks/JournalHook.cs
trunk/ManagedWinapi/Hooks/LowLevelHook.cs
trunk/ManagedWinapi/PixelData.cs
trunk/ManagedWinapi/TextCursor.cs
trunk/ManagedWinapi/TextCursorProvider.cs
trunk/ManagedWinapi/Windows/
trunk/ManagedWinapi/Windows/Contents/
trunk/ManagedWinapi/Windows/EventDispatchingNativeWindow.cs
trunk/ManagedWinapi/Windows/PInvokeTypes.cs
trunk/ManagedWinapi/Windows/Screenshot.cs
trunk/ManagedWinapi/Windows/SystemListBox.cs
trunk/ManagedWinapi/Windows/SystemListView.cs
trunk/ManagedWinapi/Windows/SystemTreeView.cs
trunk/ManagedWinapi/Windows/SystemWindow.cs
Removed Paths:
-------------
trunk/ManagedWinapi/AccessibleObjectListener.cs
trunk/ManagedWinapi/Contents/
trunk/ManagedWinapi/EventDispatchingNativeWindow.cs
trunk/ManagedWinapi/Hook.cs
trunk/ManagedWinapi/JournalHook.cs
trunk/ManagedWinapi/LowLevelHook.cs
trunk/ManagedWinapi/Mixer.cs
trunk/ManagedWinapi/MixerControl.cs
trunk/ManagedWinapi/MixerLine.cs
trunk/ManagedWinapi/PInvokeTypes.cs
trunk/ManagedWinapi/Screenshot.cs
trunk/ManagedWinapi/SystemAccessibleObject.cs
trunk/ManagedWinapi/SystemListBox.cs
trunk/ManagedWinapi/SystemListView.cs
trunk/ManagedWinapi/SystemTreeView.cs
trunk/ManagedWinapi/SystemWindow.cs
Copied: trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs (from rev 112, trunk/ManagedWinapi/AccessibleObjectListener.cs)
===================================================================
--- trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs (rev 0)
+++ trunk/ManagedWinapi/Accessibility/AccessibleObjectListener.cs 2012-07-01 16:06:19 UTC (rev 113)
@@ -0,0 +1,522 @@
+/*
+ * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
+ * access native API by managed code. http://mwinapi.sourceforge.net/
+ * Copyright (C) 2006, 2007 Michael Schierl
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; see the file COPYING. if not, visit
+ * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+using Accessibility;
+
+namespace ManagedWinapi.Accessibility
+{
+ /// <summary>
+ /// Listens to events from the Windows accessibility system. These events are useful
+ /// if you want to write a screenreader or similar program.
+ /// </summary>
+ public class AccessibleEventListener : Component
+ {
+ /// <summary>
+ /// Occurs when an accessible event is received.
+ /// </summary>
+ public event AccessibleEventHandler EventOccurred;
+
+ private bool enabled;
+ private IntPtr handle = IntPtr.Zero;
+ private AccessibleEventType min = AccessibleEventType.EVENT_MIN;
+ private AccessibleEventType max = AccessibleEventType.EVENT_MAX;
+ private WinEventDelegate internalDelegate;
+ private GCHandle gch;
+ private UInt32 processId = 0;
+ private UInt32 threadId = 0;
+
+ /// <summary>
+ /// Initializes a new instance of this class with the specified container.
+ /// </summary>
+ /// <param name="container">The container to add it to.</param>
+ public AccessibleEventListener(IContainer container)
+ : this()
+ {
+ container.Add(this);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of this class.
+ /// </summary>
+ public AccessibleEventListener()
+ {
+ internalDelegate = new WinEventDelegate(InternalCallback);
+ gch = GCHandle.Alloc(internalDelegate);
+ }
+
+ /// <summary>
+ /// Enables this listener so that it reports accessible events.
+ /// </summary>
+ public bool Enabled
+ {
+ get
+ {
+ return enabled;
+ }
+ set
+ {
+ enabled = value;
+ updateListener();
+ }
+ }
+
+ /// <summary>
+ /// The minimal event type to listen to.
+ /// </summary>
+ public AccessibleEventType MinimalEventType
+ {
+ get { return min; }
+ set { min = value; updateListener(); }
+ }
+
+ /// <summary>
+ /// The maximal event type to listen to.
+ /// </summary>
+ public AccessibleEventType MaximalEventType
+ {
+ get { return max; }
+ set { max = value; updateListener(); }
+ }
+
+ /// <summary>
+ /// The Process ID to listen to.
+ /// Default 0 listens to all processes.
+ /// </summary>
+ public UInt32 ProcessId
+ {
+ get { return processId; }
+ set { processId = value; updateListener(); }
+ }
+
+ /// <summary>
+ /// The Thread ID to listen to.
+ /// Default 0 listens to all threads.
+ /// </summary>
+ public UInt32 ThreadId
+ {
+ get { return threadId; }
+ set { threadId = value; updateListener(); }
+ }
+
+ private void updateListener()
+ {
+ if (handle != IntPtr.Zero)
+ {
+ UnhookWinEvent(handle);
+ handle = IntPtr.Zero;
+ }
+ if (enabled)
+ {
+ handle = SetWinEventHook(min, max, IntPtr.Zero, internalDelegate, processId, threadId, 0);
+ }
+ }
+
+ /// <summary>
+ /// Releases all resources used by the System.ComponentModel.Component.
+ /// </summary>
+ /// <param name="disposing">Whether to dispose managed resources.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (enabled)
+ {
+ enabled = false;
+ updateListener();
+ }
+ gch.Free();
+ base.Dispose(disposing);
+ }
+
+ private void InternalCallback(IntPtr hWinEventHook, AccessibleEventType eventType,
+ IntPtr hwnd, uint idObject, uint idChild, uint dwEventThread, uint dwmsEventTime)
+ {
+ if (hWinEventHook != handle) return;
+ AccessibleEventArgs aea = new AccessibleEventArgs(eventType, hwnd, idObject, idChild, dwEventThread, dwmsEventTime);
+ if (EventOccurred != null)
+ EventOccurred(this, aea);
+ }
+
+ internal static SystemAccessibleObject GetAccessibleObject(AccessibleEventArgs e)
+ {
+ IAccessible iacc;
+ object child;
+ uint result = AccessibleObjectFromEvent(e.HWnd, e.ObjectID, e.ChildID, out iacc, out child);
+ if (result != 0) throw new Exception("AccessibleObjectFromPoint returned " + result);
+ return new SystemAccessibleObject(iacc, (int)child);
+ }
+
+ #region PInvoke Declarations
+
+ [DllImport("user32.dll")]
+ private static extern IntPtr SetWinEventHook(AccessibleEventType eventMin, AccessibleEventType eventMax, IntPtr
+ hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess,
+ uint idThread, uint dwFlags);
+
+ [DllImport("user32.dll")]
+ static extern bool UnhookWinEvent(IntPtr hWinEventHook);
+
+ private delegate void WinEventDelegate(IntPtr hWinEventHook, AccessibleEventType eventType,
+ IntPtr hwnd, uint idObject, uint idChild, uint dwEventThread, uint dwmsEventTime);
+
+ [DllImport("oleacc.dll")]
+ private static extern uint AccessibleObjectFromEvent(IntPtr hwnd, uint dwObjectID, uint dwChildID, out IAccessible ppacc, [MarshalAs(UnmanagedType.Struct)] out object pvarChild);
+
+ #endregion
+ }
+
+ /// <summary>
+ /// Represents the method that will handle accessibility events.
+ /// </summary>
+ public delegate void AccessibleEventHandler(object sender, AccessibleEventArgs e);
+
+ /// <summary>
+ /// Provides data for accessible events.
+ /// </summary>
+ public class AccessibleEventArgs : EventArgs
+ {
+ private AccessibleEventType eventType;
+ private IntPtr hWnd;
+ private uint idObject;
+ private uint idChild;
+ private uint dwEventThread;
+ private uint dwmsEventTime;
+
+ /// <summary>
+ /// Initializes a new instance of the AccessibleEventArgs class.
+ /// </summary>
+ public AccessibleEventArgs(AccessibleEventType eventType,
+ IntPtr hwnd, uint idObject, uint idChild, uint dwEventThread, uint dwmsEventTime)
+ {
+ this.eventType = eventType;
+ this.hWnd = hwnd;
+ this.idObject = idObject;
+ this.idChild = idChild;
+ this.dwEventThread = dwEventThread;
+ this.dwmsEventTime = dwmsEventTime;
+ }
+
+ /// <summary>
+ /// Type of this accessible event
+ /// </summary>
+ public AccessibleEventType EventType
+ {
+ get { return eventType; }
+ }
+
+ /// <summary>
+ /// Handle of the affected window, if any.
+ /// </summary>
+ public IntPtr HWnd
+ {
+ get { return hWnd; }
+ }
+
+ /// <summary>
+ /// Object ID.
+ /// </summary>
+ public uint ObjectID
+ {
+ get { return idObject; }
+ }
+
+ /// <summary>
+ /// Child ID.
+ /// </summary>
+ public uint ChildID
+ {
+ get { return idChild; }
+ }
+
+ /// <summary>
+ /// The thread that generated this event.
+ /// </summary>
+ public uint Thread
+ {
+ get { return dwEventThread; }
+ }
+
+ /// <summary>
+ /// Time in milliseconds when the event was generated.
+ /// </summary>
+ public uint Time
+ {
+ get { return dwmsEventTime; }
+ }
+
+ /// <summary>
+ /// The accessible object related to this event.
+ /// </summary>
+ public SystemAccessibleObject AccessibleObject
+ {
+ get
+ {
+ return AccessibleEventListener.GetAccessibleObject(this);
+ }
+ }
+ }
+
+ /// <summary>
+ /// This enumeration lists known accessible event types.
+ /// </summary>
+ public enum AccessibleEventType
+ {
+ /// <summary>
+ /// Sent when a sound is played. Currently nothing is generating this, we
+ /// are going to be cleaning up the SOUNDSENTRY feature in the control panel
+ /// and will use this at that time. Applications implementing WinEvents
+ /// are perfectly welcome to use it. Clients of IAccessible* will simply
+ /// turn around and get back a non-visual object that describes the sound.
+ /// </summary>
+ EVENT_SYSTEM_SOUND = 0x0001,
+
+ /// <summary>
+ /// Sent when an alert needs to be given to the user. MessageBoxes generate
+ /// alerts for example.
+ /// </summary>
+ EVENT_SYSTEM_ALERT = 0x0002,
+
+ /// <summary>
+ /// Sent when the foreground (active) window changes, even if it is changing
+ /// to another window in the same thread as the previous one.
+ /// </summary>
+ EVENT_SYSTEM_FOREGROUND = 0x0003,
+
+ /// <summary>
+ /// Sent when entering into and leaving from menu mode (system, app bar, and
+ /// track popups).
+ /// </summary>
+ EVENT_SYSTEM_MENUSTART = 0x0004,
+
+ /// <summary>
+ /// Sent when entering into and leaving from menu mode (system, app bar, and
+ /// track popups).
+ /// </summary>
+ EVENT_SYSTEM_MENUEND = 0x0005,
+
+ /// <summary>
+ /// Sent when a menu popup comes up and just before it is taken down. Note
+ /// that for a call to TrackPopupMenu(), a client will see EVENT_SYSTEM_MENUSTART
+ /// followed almost immediately by EVENT_SYSTEM_MENUPOPUPSTART for the popup
+ /// being shown.
+ /// </summary>
+ EVENT_SYSTEM_MENUPOPUPSTART = 0x0006,
+
+ /// <summary>
+ /// Sent when a menu popup comes up and just before it is taken down. Note
+ /// that for a call to TrackPopupMenu(), a client will see EVENT_SYSTEM_MENUSTART
+ /// followed almost immediately by EVENT_SYSTEM_MENUPOPUPSTART for the popup
+ /// being shown.
+ /// </summary>
+ EVENT_SYSTEM_MENUPOPUPEND = 0x0007,
+
+
+ /// <summary>
+ /// Sent when a window takes the capture and releases the capture.
+ /// </summary>
+ EVENT_SYSTEM_CAPTURESTART = 0x0008,
+
+ /// <summary>
+ /// Sent when a window takes the capture and releases the capture.
+ /// </summary>
+ EVENT_SYSTEM_CAPTUREEND = 0x0009,
+
+ /// <summary>
+ /// Sent when a window enters and leaves move-size dragging mode.
+ /// </summary>
+ EVENT_SYSTEM_MOVESIZESTART = 0x000A,
+
+ /// <summary>
+ /// Sent when a window enters and leaves move-size dragging mode.
+ /// </summary>
+ EVENT_SYSTEM_MOVESIZEEND = 0x000B,
+
+ /// <summary>
+ /// Sent when a window enters and leaves context sensitive help mode.
+ /// </summary>
+ EVENT_SYSTEM_CONTEXTHELPSTART = 0x000C,
+
+ /// <summary>
+ /// Sent when a window enters and leaves context sensitive help mode.
+ /// </summary>
+ EVENT_SYSTEM_CONTEXTHELPEND = 0x000D,
+
+ /// <summary>
+ /// Sent when a window enters and leaves drag drop mode. Note that it is up
+ /// to apps and OLE to generate this, since the system doesn't know. Like
+ /// EVENT_SYSTEM_SOUND, it will be a while before this is prevalent.
+ /// </summary>
+ EVENT_SYSTEM_DRAGDROPSTART = 0x000E,
+
+ /// <summary>
+ /// Sent when a window enters and leaves drag drop mode. Note that it is up
+ /// to apps and OLE to generate this, since the system doesn't know. Like
+ /// EVENT_SYSTEM_SOUND, it will be a while before this is prevalent.
+ /// </summary>
+ EVENT_SYSTEM_DRAGDROPEND = 0x000F,
+
+ /// <summary>
+ /// Sent when a dialog comes up and just before it goes away.
+ /// </summary>
+ EVENT_SYSTEM_DIALOGSTART = 0x0010,
+
+ /// <summary>
+ /// Sent when a dialog comes up and just before it goes away.
+ /// </summary>
+ EVENT_SYSTEM_DIALOGEND = 0x0011,
+
+ /// <summary>
+ /// Sent when beginning and ending the tracking of a scrollbar in a window,
+ /// and also for scrollbar controls.
+ /// </summary>
+ EVENT_SYSTEM_SCROLLINGSTART = 0x0012,
+
+ /// <summary>
+ /// Sent when beginning and ending the tracking of a scrollbar in a window,
+ /// and also for scrollbar controls.
+ /// </summary>
+ EVENT_SYSTEM_SCROLLINGEND = 0x0013,
+
+ /// <summary>
+ /// Sent when beginning and ending alt-tab mode with the switch window.
+ /// </summary>
+ EVENT_SYSTEM_SWITCHSTART = 0x0014,
+
+ /// <summary>
+ /// Sent when beginning and ending alt-tab mode with the switch window.
+ /// </summary>
+ EVENT_SYSTEM_SWITCHEND = 0x0015,
+
+ /// <summary>
+ /// Sent when a window minimizes.
+ /// </summary>
+ EVENT_SYSTEM_MINIMIZESTART = 0x0016,
+
+ /// <summary>
+ /// Sent just before a window restores.
+ /// </summary>
+ EVENT_SYSTEM_MINIMIZEEND = 0x0017,
+
+ /// <summary>
+ /// hwnd + ID + idChild is created item
+ /// </summary>
+ EVENT_OBJECT_CREATE = 0x8000,
+
+ /// <summary>
+ /// hwnd + ID + idChild is destroyed item
+ /// </summary>
+ EVENT_OBJECT_DESTROY = 0x8001,
+
+ /// <summary>
+ /// hwnd + ID + idChild is shown item
+ /// </summary>
+ EVENT_OBJECT_SHOW = 0x8002,
+
+ /// <summary>
+ /// hwnd + ID + idChild is hidden item
+ /// </summary>
+ EVENT_OBJECT_HIDE = 0x8003,
+
+ /// <summary>
+ /// hwnd + ID + idChild is parent of zordering children
+ /// </summary>
+ EVENT_OBJECT_REORDER = 0x8004,
+
+ /// <summary>
+ /// hwnd + ID + idChild is focused item
+ /// </summary>
+ EVENT_OBJECT_FOCUS = 0x8005,
+
+ /// <summary>
+ /// hwnd + ID + idChild is selected item (if only one), or idChild is OBJID_WINDOW if complex
+ /// </summary>
+ EVENT_OBJECT_SELECTION = 0x8006,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item added
+ /// </summary>
+ EVENT_OBJECT_SELECTIONADD = 0x8007,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item removed
+ /// </summary>
+ EVENT_OBJECT_SELECTIONREMOVE = 0x8008,
+
+ /// <summary>
+ /// hwnd + ID + idChild is parent of changed selected items
+ /// </summary>
+ EVENT_OBJECT_SELECTIONWITHIN = 0x8009,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item w/ state change
+ /// </summary>
+ EVENT_OBJECT_STATECHANGE = 0x800A,
+
+ /// <summary>
+ /// hwnd + ID + idChild is moved/sized item
+ /// </summary>
+ EVENT_OBJECT_LOCATIONCHANGE = 0x800B,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item w/ name change
+ /// </summary>
+ EVENT_OBJECT_NAMECHANGE = 0x800C,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item w/ desc change
+ /// </summary>
+ EVENT_OBJECT_DESCRIPTIONCHANGE = 0x800D,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item w/ value change
+ /// </summary>
+ EVENT_OBJECT_VALUECHANGE = 0x800E,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item w/ new parent
+ /// </summary>
+ EVENT_OBJECT_PARENTCHANGE = 0x800F,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item w/ help change
+ /// </summary>
+ EVENT_OBJECT_HELPCHANGE = 0x8010,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item w/ def action change
+ /// </summary>
+ EVENT_OBJECT_DEFACTIONCHANGE = 0x8011,
+
+ /// <summary>
+ /// hwnd + ID + idChild is item w/ keybd accel change
+ /// </summary>
+ EVENT_OBJECT_ACCELERATORCHANGE = 0x8012,
+
+ /// <summary>
+ /// The lowest possible event value
+ /// </summary>
+ EVENT_MIN = 0x00000001,
+
+ /// <summary>
+ /// The highest possible event value
+ /// </summary>
+ EVENT_MAX = 0x7FFFFFFF,
+ }
+}
Copied: trunk/ManagedWinapi/Accessibility/SystemAccessibleObject.cs (from rev 112, trunk/ManagedWinapi/SystemAccessibleObject.cs)
===================================================================
--- trunk/ManagedWinapi/Accessibility/SystemAccessibleObject.cs (rev 0)
+++ trunk/ManagedWinapi/Accessibility/SystemAccessibleObject.cs 2012-07-01 16:06:19 UTC (rev 113)
@@ -0,0 +1,708 @@
+/*
+ * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
+ * access native API by managed code. http://mwinapi.sourceforge.net/
+ * Copyright (C) 2006 Michael Schierl
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; see the file COPYING. if not, visit
+ * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Accessibility;
+using ManagedWinapi.Windows;
+using System.Runtime.InteropServices;
+using System.Drawing;
+using System.Runtime.InteropServices.ComTypes;
+
+namespace ManagedWinapi.Accessibility
+{
+ /// <summary>
+ /// Provides access to the Active Accessibility API. Every <see cref="SystemWindow"/>
+ /// has one ore more AccessibleObjects attached that provide information about the
+ /// window to visually impaired people. This information is mainly used by screen
+ /// readers and other accessibility software..
+ /// </summary>
+ public class SystemAccessibleObject
+ {
+ private IAccessible iacc;
+ private int childID;
+
+ /// <summary>
+ /// The IAccessible instance of this object (if <see cref="ChildID"/> is zero)
+ /// or its parent.
+ /// </summary>
+ public IAccessible IAccessible { get { return iacc; } }
+
+ /// <summary>
+ /// The underlying child ID
+ /// </summary>
+ public int ChildID { get { return childID; } }
+
+ /// <summary>
+ /// Create an accessible object from an IAccessible instance and a child ID.
+ /// </summary>
+ public SystemAccessibleObject(IAccessible iacc, int childID)
+ {
+ if (iacc == null) throw new ArgumentNullException();
+ //if (childID < 0) throw new ArgumentException();
+ if (childID != 0)
+ {
+ try
+ {
+ object realChild = iacc.get_accChild(childID);
+ if (realChild != null)
+ {
+ iacc = (IAccessible)realChild;
+ childID = 0;
+ }
+ }
+ catch (ArgumentException) { }
+ catch (InvalidCastException) { }
+ }
+ this.iacc = iacc;
+ this.childID = childID;
+ }
+
+ /// <summary>
+ /// Gets an accessibility object for given screen coordinates.
+ /// </summary>
+ public static SystemAccessibleObject FromPoint(int x, int y)
+ {
+ IAccessible iacc;
+ object ci;
+ IntPtr result = AccessibleObjectFromPoint(new ManagedWinapi.Windows.POINT(x, y), out iacc, out ci);
+ if (result != IntPtr.Zero) throw new Exception("AccessibleObjectFromPoint returned " + result.ToInt32());
+ return new SystemAccessibleObject(iacc, (int)(ci ?? 0));
+ }
+
+ /// <summary>
+ /// Gets an accessibility object for a given window.
+ /// </summary>
+ /// <param name="window">The window</param>
+ /// <param name="objectID">Which accessibility object to get</param>
+ /// <returns></returns>
+ public static SystemAccessibleObject FromWindow(SystemWindow window, AccessibleObjectID objectID)
+ {
+ IAccessible iacc = (IAccessible)AccessibleObjectFromWindow(window == null ? IntPtr.Zero : window.HWnd, (uint)objectID, new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}"));
+ return new SystemAccessibleObject(iacc, 0);
+ }
+
+ /// <summary>
+ /// Gets the automation object for a given window.
+ /// This is a COM object implementing the IDispatch interface, commonly
+ /// available from Microsoft Office windows.
+ /// </summary>
+ /// <param name="window">The window</param>
+ public static object COMObjectFromWindow(SystemWindow window)
+ {
+ return AccessibleObjectFromWindow(window == null ? IntPtr.Zero : window.HWnd, OBJID_NATIVEOM, new Guid("{00020400-0000-0000-C000-000000000046}"));
+ }
+
+ /// <summary>
+ /// Gets an accessibility object for the mouse cursor.
+ /// </summary>
+ public static SystemAccessibleObject MouseCursor
+ {
+ get
+ {
+ return FromWindow(null, AccessibleObjectID.OBJID_CURSOR);
+ }
+ }
+
+ /// <summary>
+ /// Gets an accessibility object for the input caret, or
+ /// <b>null</b> if there is none.
+ /// </summary>
+ public static SystemAccessibleObject Caret
+ {
+ get
+ {
+ try
+ {
+ return FromWindow(null, AccessibleObjectID.OBJID_CARET);
+ }
+ catch (COMException)
+ {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Convert a role number to a localized string.
+ /// </summary>
+ public static string RoleToString(int roleNumber)
+ {
+ StringBuilder sb = new StringBuilder(1024);
+ uint result = GetRoleText((uint)roleNumber, sb, 1024);
+ if (result == 0) throw new Exception("Invalid role number");
+ return sb.ToString();
+ }
+
+ /// <summary>
+ /// Convert a state number (which may include more than one state bit)
+ /// to a localized string.
+ /// </summary>
+ public static String StateToString(int stateNumber)
+ {
+ if (stateNumber == 0) return "None";
+ int lowBit = stateNumber & -stateNumber;
+ int restBits = stateNumber - lowBit;
+ String s1 = StateBitToString(lowBit);
+ if (restBits == 0) return s1;
+ return StateToString(restBits) + ", " + s1;
+ }
+
+ /// <summary>
+ /// Convert a single state bit to a localized string.
+ /// </summary>
+ public static string StateBitToString(int stateBit)
+ {
+ StringBuilder sb = new StringBuilder(1024);
+ uint result = GetStateText((uint)stateBit, sb, 1024);
+ if (result == 0) throw new Exception("Invalid role number");
+ return sb.ToString();
+ }
+
+ /// <summary>
+ /// The description of this accessible object.
+ /// </summary>
+ public string Description
+ {
+ get
+ {
+ try
+ {
+ return iacc.get_accDescription(childID);
+ }
+ catch (NotImplementedException)
+ {
+ return "";
+ }
+ }
+ }
+
+ /// <summary>
+ /// The name of this accessible object.
+ /// </summary>
+ public string Name
+ {
+ get
+ {
+ return iacc.get_accName(childID);
+ }
+ }
+
+ /// <summary>
+ /// The role of this accessible object. This can either be an int
+ /// (for a predefined role) or a string.
+ /// </summary>
+ public object Role
+ {
+ get
+ {
+ return iacc.get_accRole(childID);
+ }
+ }
+
+ /// <summary>
+ /// The role of this accessible object, as an integer. If this role
+ /// is not predefined, -1 is returned.
+ /// </summary>
+ public int RoleIndex
+ {
+ get
+ {
+ object role = Role;
+ if (role is int)
+ {
+ return (int)role;
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ }
+
+ /// <summary>
+ /// The role of this accessible object, as a localized string.
+ /// </summary>
+ public string RoleString
+ {
+ get
+ {
+ object role = Role;
+ if (role is int)
+ {
+ return RoleToString((int)role);
+ }
+ else if (role is string)
+ {
+ return (string)role;
+ }
+ else
+ {
+ return role.ToString();
+ }
+ }
+ }
+
+ /// <summary>
+ /// The location of this accessible object on screen. This rectangle
+ /// is the smallest rectangle that includes the whole object, but not
+ /// every point in the rectangle must be part of the object.
+ /// </summary>
+ public Rectangle Location
+ {
+ get
+ {
+ int x, y, w, h;
+ iacc.accLocation(out x, out y, out w, out h, childID);
+ return new Rectangle(x, y, w, h);
+
+ }
+ }
+
+ /// <summary>
+ /// The value of this accessible object.
+ /// </summary>
+ public string Value
+ {
+ get
+ {
+ try
+ {
+ return iacc.get_accValue(childID);
+ }
+ catch (COMException)
+ {
+ return null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// The state of this accessible object.
+ /// </summary>
+ public int State
+ {
+ get
+ {
+ try
+ {
+ return (int)iacc.get_accState(childID);
+ }
+ catch (COMException)
+ {
+ return 0;
+ }
+ }
+ }
+
+ /// <summary>
+ /// A string representation of the state of this accessible object.
+ /// </summary>
+ public string StateString
+ {
+ get
+ {
+ return StateToString(State);
+ }
+ }
+
+ /// <summary>
+ /// Whether this accessibile object is visible.
+ /// </summary>
+ public bool Visible
+ {
+ get
+ {
+ return (State & 0x8000) == 0;
+ }
+ }
+
+ /// <summary>
+ /// The parent of this accessible object, or <b>null</b> if none exists.
+ /// </summary>
+ public SystemAccessibleObject Parent
+ {
+ get
+ {
+ if (childID != 0) return new SystemAccessibleObject(iacc, 0);
+ IAccessible p = (IAccessible)iacc.accParent;
+ if (p == null) return null;
+ return new SystemAccessibleObject(p, 0);
+ }
+ }
+
+ /// <summary>
+ /// The keyboard shortcut of this accessible object.
+ /// </summary>
+ public string KeyboardShortcut
+ {
+ get
+ {
+ try
+ {
+ return iacc.get_accKeyboardShortcut(childID);
+ }
+ catch (ArgumentException) { return ""; }
+ catch (NotImplementedException) { return ""; }
+ catch (COMException) { return null; }
+ }
+ }
+
+ /// <summary>
+ /// A string describing the default action of this accessible object.
+ /// For a button, this might be "Press".
+ /// </summary>
+ public string DefaultAction
+ {
+ get
+ {
+ try
+ {
+ return iacc.get_accDefaultAction(childID);
+ }
+ catch (COMException) { return null; }
+ }
+ }
+
+ /// <summary>
+ /// Perform the default action of this accessible object.
+ /// </summary>
+ public void DoDefaultAction()
+ {
+ iacc.accDoDefaultAction(ChildID);
+ }
+
+ /// <summary>
+ /// Get all objects of this accessible object that are selected.
+ /// </summary>
+ public SystemAccessibleObject[] SelectedObjects
+ {
+ get
+ {
+ if (childID != 0) return new SystemAccessibleObject[0];
+ object sel;
+ try
+ {
+ sel = iacc.accSelection;
+ }
+ catch (NotImplementedException)
+ {
+ return new SystemAccessibleObject[0];
+ }
+ catch (COMException)
+ {
+ return new SystemAccessibleObject[0];
+ }
+ if (sel == null) return new SystemAccessibleObject[0];
+ if (sel is IEnumVARIANT)
+ {
+ IEnumVARIANT e = (IEnumVARIANT)sel;
+ e.Reset();
+ List<SystemAccessibleObject> retval = new List<SystemAccessibleObject>();
+ object[] tmp = new object[1];
+ while (e.Next(1, tmp, IntPtr.Zero) == 0)
+ {
+ if (tmp[0] is int && (int)tmp[0] < 0) break;
+ retval.Add(ObjectToSAO(tmp[0]));
+ }
+ return retval.ToArray();
+ }
+ else
+ {
+ if (sel is int && (int)sel < 0)
+ {
+ return new SystemAccessibleObject[0];
+ }
+ return new SystemAccessibleObject[] { ObjectToSAO(sel) };
+ }
+ }
+ }
+
+ private SystemAccessibleObject ObjectToSAO(object obj)
+ {
+ if (obj is int)
+ {
+ return new SystemAccessibleObject(iacc, (int)obj);
+ }
+ else
+ {
+ return new SystemAccessibleObject((IAccessible)obj, 0);
+ }
+ }
+
+ /// <summary>
+ /// Get the SystemWindow that owns this accessible object.
+ /// </summary>
+ public SystemWindow Window
+ {
+ get
+ {
+ IntPtr hwnd;
+ WindowFromAccessibleObject(iacc, out hwnd);
+ return new SystemWindow(hwnd);
+ }
+ }
+
+ /// <summary>
+ /// Get all child accessible objects.
+ /// </summary>
+ public SystemAccessibleObject[] Children
+ {
+ get
+ {
+ // ID-referenced objects cannot have children
+ if (childID != 0) return new SystemAccessibleObject[0];
+
+ int cs = iacc.accChildCount, csReal;
+ object[] children = new object[cs * 2];
+
+ uint result = AccessibleChildren(iacc, 0, cs * 2, children, out csReal);
+ if (result != 0 && result != 1)
+ return new SystemAccessibleObject[0];
+ if (csReal == 1 && children[0] is int && (int)children[0] < 0)
+ return new SystemAccessibleObject[0];
+ List<SystemAccessibleObject> values = new List<SystemAccessibleObject>();
+ for (int i = 0; i < children.Length; i++)
+ {
+ if (children[i] != null)
+ {
+ try
+ {
+ values.Add(ObjectToSAO(children[i]));
+ }
+ catch (InvalidCastException) { }
+ }
+ }
+ return values.ToArray();
+ }
+ }
+
+ /// <summary>
+ /// Highlight the accessible object with a red border.
+ /// </summary>
+ public void Highlight()
+ {
+ Rectangle objectLocation = Location;
+ SystemWindow window = Window;
+ Rectangle windowLocation = window.Rectangle;
+ using (WindowDeviceContext windowDC = window.GetDeviceContext(false))
+ {
+ using (Graphics g = windowDC.CreateGraphics())
+ {
+ g.DrawRectangle(new Pen(Color.Red, 4), objectLocation.X - windowLocation.X, objectLocation.Y - windowLocation.Y, objectLocation.Width, objectLocation.Height);
+ }
+ }
+ }
+
+ #region Equals and HashCode
+
+ ///
+ public override bool Equals(System.Object obj)
+ {
+ if (obj == null)
+ {
+ return false;
+ }
+ SystemAccessibleObject sao = obj as SystemAccessibleObject;
+ return Equals(sao);
+ }
+
+ ///
+ public bool Equals(SystemAccessibleObject sao)
+ {
+ if ((object)sao == null)
+ {
+ return false;
+ }
+ return childID == sao.childID && DeepEquals(iacc, sao.iacc);
+ }
+
+ private static bool DeepEquals(IAccessible ia1, IAccessible ia2)
+ {
+ if (ia1.Equals(ia2)) return true;
+ if (Marshal.GetIUnknownForObject(ia1) == Marshal.GetIUnknownForObject(ia2)) return true;
+ try
+ {
+ if (ia1.accChildCount != ia2.accChildCount) return false;
+ SystemAccessibleObject sa1 = new SystemAccessibleObject(ia1, 0);
+ SystemAccessibleObject sa2 = new SystemAccessibleObject(ia2, 0);
+ if (sa1.Window.HWnd != sa2.Window.HWnd) return false;
+ if (sa1.Location != sa2.Location) return false;
+ if (sa1.DefaultAction != sa2.DefaultAction) return false;
+ if (sa1.Description != sa2.Description) return false;
+ if (sa1.KeyboardShortcut != sa2.KeyboardShortcut) return false;
+ if (sa1.Name != sa2.Name) return false;
+ if (!sa1.Role.Equals(sa2.Role)) return false;
+ if (sa1.State != sa2.State) return false;
+ if (sa1.Value != sa2.Value) return false;
+ if (sa1.Visible != sa2.Visible) return false;
+ if (ia1.accParent == null && ia2.accParent == null) return true;
+ if (ia1.accParent == null || ia2.accParent == null) return false;
+ }
+ catch (COMException)
+ {
+ return false;
+ }
+ bool de = DeepEquals((IAccessible)ia1.accParent, (IAccessible)ia2.accParent);
+ return de;
+ }
+
+ ///
+ public override int GetHashCode()
+ {
+ return childID ^ iacc.GetHashCode();
+ }
+
+ /// <summary>
+ /// Compare two instances of this class for equality.
+ /// </summary>
+ public static bool operator ==(SystemAccessibleObject a, SystemAccessibleObject b)
+ {
+ if (System.Object.ReferenceEquals(a, b))
+ {
+ return true;
+ }
+ if (((object)a == null) || ((object)b == null))
+ {
+ return false;
+ }
+ return a.iacc == b.iacc && a.childID == b.childID;
+ }
+
+ /// <summary>
+ /// Compare two instances of this class for inequality.
+ /// </summary>
+ public static bool operator !=(SystemAccessibleObject a, SystemAccessibleObject b)
+ {
+ return !(a == b);
+ }
+
+ ///
+ public override string ToString()
+ {
+ try
+ {
+ return Name + " [" + RoleString + "]";
+ }
+ catch
+ {
+ return "??";
+ }
+ }
+
+ #endregion
+
+ #region PInvoke Declarations
+
+ const uint OBJID_NATIVEOM = 0xFFFFFFF0;
+
+ [DllImport("oleacc.dll")]
+ private static extern IntPtr AccessibleObjectFromPoint(POINT pt, [Out, MarshalAs(UnmanagedType.Interface)] out IAccessible accObj, [Out] out object ChildID);
+ [DllImport("oleacc.dll")]
+ private static extern uint GetRoleText(uint dwRole, [Out] StringBuilder lpszRole, uint cchRoleMax);
+
+ [DllImport("oleacc.dll", ExactSpelling = true, PreserveSig = false)]
+ [return: MarshalAs(UnmanagedType.Interface)]
+ private static extern object AccessibleObjectFromWindow(
+ IntPtr hwnd,
+ uint dwObjectID,
+ [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid);
+
+ [DllImport("oleacc.dll")]
+ private static extern uint GetStateText(uint dwStateBit, [Out] StringBuilder lpszStateBit, uint cchStateBitMax);
+
+ [DllImport("oleacc.dll")]
+ private static extern uint WindowFromAccessibleObject(IAccessible pacc, out IntPtr phwnd);
+
+ [DllImport("oleacc.dll")]
+ private static extern uint AccessibleChildren(IAccessible paccContainer, int iChildStart, int cChildren, [Out] object[] rgvarChildren, out int pcObtained);
+
+ #endregion
+ }
+
+ /// <summary>
+ /// This enumeration lists all kinds of accessible objects that can
+ /// be directly assigned to a window.
+ /// </summary>
+ public enum AccessibleObjectID : uint
+ {
+ /// <summary>
+ /// The window itself.
+ /// </summary>
+ OBJID_WINDOW = 0x00000000,
+
+ /// <summary>
+ /// The system menu.
+ /// </summary>
+ OBJID_SYSMENU = 0xFFFFFFFF,
+
+ /// <summary>
+ /// The title bar.
+ /// </summary>
+ OBJID_TITLEBAR = 0xFFFFFFFE,
+
+ /// <summary>
+ /// The menu.
+ /// </summary>
+ OBJID_MENU = 0xFFFFFFFD,
+
+ /// <summary>
+ /// The client area.
+ /// </summary>
+ OBJID_CLIENT = 0xFFFFFFFC,
+
+ /// <summary>
+ /// The vertical scroll bar.
+ /// </summary>
+ OBJID_VSCROLL = 0xFFFFFFFB,
+
+ /// <summary>
+ /// The horizontal scroll bar.
+ /// </summary>
+ OBJID_HSCROLL = 0xFFFFFFFA,
+
+ /// <summary>
+ /// The size grip (part in the lower right corner that
+ /// makes resizing the window easier).
+ /// </summary>
+ OBJID_SIZEGRIP = 0xFFFFFFF9,
+
+ /// <summary>
+ /// The caret (text cursor).
+ /// </summary>
+ OBJID_CARET = 0xFFFFFFF8,
+
+ /// <summary>
+ /// The mouse cursor. There is only one mouse
+ /// cursor and it is not assigned to any window.
+ /// </summary>
+ OBJID_CURSOR = 0xFFFFFFF7,
+
+ /// <summary>
+ /// An alert window.
+ /// </summary>
+ OBJID_ALERT = 0xFFFFFFF6,
+
+ /// <summary>
+ /// A sound this window is playing.
+ /// </summary>
+ OBJID_SOUND = 0xFFFFFFF5
+ }
+}
Deleted: trunk/ManagedWinapi/AccessibleObjectListener.cs
===================================================================
--- trunk/ManagedWinapi/AccessibleObjectListener.cs 2012-04-20 16:24:56 UTC (rev 112)
+++ trunk/ManagedWinapi/AccessibleObjectListener.cs 2012-07-01 16:06:19 UTC (rev 113)
@@ -1,522 +0,0 @@
-/*
- * ManagedWinapi - A collection of .NET components that wrap PInvoke calls to
- * access native API by managed code. http://mwinapi.sourceforge.net/
- * Copyright (C) 2006, 2007 Michael Schierl
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; see the file COPYING. if not, visit
- * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-using System;
-using System.ComponentModel;
-using System.Runtime.InteropServices;
-using Accessibility;
-
-namespace ManagedWinapi.Accessibility
-{
- /// <summary>
- /// Listens to events from the Windows accessibility system. These events are useful
- /// if you want to write a screenreader or similar program.
- /// </summary>
- public class AccessibleEventListener : Component
- {
- /// <summary>
- /// Occurs when an accessible event is received.
- /// </summary>
- public event AccessibleEventHandler EventOccurred;
-
- private bool enabled;
- private IntPtr handle = IntPtr.Zero;
- private AccessibleEventType min = AccessibleEventType.EVENT_MIN;
- private AccessibleEventType max = AccessibleEventType.EVENT_MAX;
- private WinEventDelegate internalDelegate;
- private GCHandle gch;
- private UInt32 processId = 0;
- private UInt32 threadId = 0;
-
- /// <summary>
- /// Initializes a new instance of this class with the specified container.
- /// </summary>
- /// <param name="container">The container to add it to.</param>
- public AccessibleEventListener(IContainer container)
- : this()
- {
- container.Add(this);
- }
-
- /// <summary>
- /// Initializes a new instance of this class.
- /// </summary>
- public AccessibleEventListener()
- {
- internalDelegate = new WinEventDelegate(InternalCallback);
- gch = GCHandle.Alloc(internalDelegate);
- }
-
- /// <summary>
- /// Enables this listener so that it reports accessible events.
- /// </summary>
- public bool Enabled
- {
- get
- {
- return enabled;
- }
- set
- {
- enabled = value;
- updateListener();
- }
- }
-
- /// <summary>
- /// The minimal event type to listen to.
- /// </summary>
- public AccessibleEventType MinimalEventType
- {
- get { return min; }
- set { min = value; updateListener(); }
- }
-
- /// <summary>
- /// The maximal event type to listen to.
- /// </summary>
- public AccessibleEventType MaximalEventType
- {
- get { return max; }
- set { max = value; updateListener(); }
- }
-
- /// <summary>
- /// The Process ID to listen to.
- /// Default 0 listens to all processes.
- /// </summary>
- public UInt32 ProcessId
- {
- get { return processId; }
- set { processId = value; updateListener(); }
- }
-
- /// <summary>
- /// The Thread ID to listen to.
- /// Default 0 listens to all threads.
- /// </summary>
- public UInt32 ThreadId
- {
- get { return threadId; }
- set { threadId = value; updateListener(); }
- }
-
- private void updateListener()
- {
- if (handle != IntPtr.Zero)
- {
- UnhookWinEvent(handle);
- handle = IntPtr.Zero;
- }
- if (enabled)
- {
- handle = SetWinEventHook(min, max, IntPtr.Zero, internalDelegate, processId, threadId, 0);
- }
- }
-
- /// <summary>
- /// Releases all resources used by the System.ComponentModel.Component.
- /// </summary>
- /// <param name="disposing">Whether to dispose managed resources.</param>
- protected override void Dispose(bool disposing)
- {
- if (enabled)
- {
- enabled = false;
- updateListener();
- }
- gch.Free();
- base.Dispose(disposing);
- }
-
- private void InternalCallback(IntPtr hWinEventHook, AccessibleEventType eventType,
- IntPtr hwnd, uint idObject, uint idChild, uint dwEventThread, uint dwmsEventTime)
- {
- if (hWinEventHook != handle) return;
- AccessibleEventArgs aea = new AccessibleEventArgs(eventType, hwnd, idObject, idChild, dwEventThread, dwmsEventTime);
- if (EventOccurred != null)
- EventOccurred(this, aea);
- }
-
- internal static SystemAccessibleObject GetAccessibleObject(AccessibleEventArgs e)
- {
- IAccessible iacc;
- object child;
- uint result = AccessibleObjectFromEvent(e.HWnd, e.ObjectID, e.ChildID, out iacc, out child);
- if (result != 0) throw new Exception("AccessibleObjectFromPoint returned " + result);
- return new SystemAccessibleObject(iacc, (int)child);
- }
-
- #region PInvoke Declarations
-
- [DllImport("user32.dll")]
- private static extern IntPtr SetWinEventHook(AccessibleEventType eventMin, AccessibleEventType eventMax, IntPtr
- hmodWinEventProc, WinEventDelegate lpfnWinEventProc, uint idProcess,
- uint idThread, uint dwFlags);
-
- [DllImport("user32.dll")]
- static extern bool UnhookWinEvent(IntPtr hWinEventHook);
-
- private delegate void WinEventDelegate(IntPtr hWinEventHook, AccessibleEventType eventType,
- IntPtr hwnd, uint idObject, uint idChild, uint dwEventThread, uint dwmsEventTime);
-
- [DllImport("oleacc.dll")]
- private static extern uint AccessibleObjectFromEvent(IntPtr hwnd, uint dwObjectID, uint dwChildID, out IAccessible ppacc, [MarshalAs(UnmanagedType.Struct)] out object pvarChild);
-
- #endregion
- }
-
- /// <summary>
- /// Represents the method that will handle accessibility events.
- /// </summary>
- public delegate void AccessibleEventHandler(object sender, AccessibleEventArgs e);
-
- /// <summary>
- /// Provides data for accessible events.
- /// </summary>
- public class AccessibleEventArgs : EventArgs
- {
- private AccessibleEventType eventType;
- private IntPtr hWnd;
- private uint idObject;
- private uint idChild;
- private uint dwEventThread;
- private uint dwmsEventTime;
-
- /// <summary>
- /// Initializes a new instance of the AccessibleEventArgs class.
- /// </summary>
- public AccessibleEventArgs(AccessibleEventType eventType,
- IntPtr hwnd, uint idObject, uint idChild, uint dwEventThread, uint dwmsEventTime)
- {
- this.eventType = eventType;
- this.hWnd = hwnd;
- this.idObject = idObject;
- this.idChild = idChild;
- this.dwEventThread = dwEventThread;
- this.dwmsEventTime = dwmsEventTime;
- }
-
- /// <summary>
- /// Type of this accessible event
- /// </summary>
- public AccessibleEventType EventType
- {
- get { return eventType; }
- }
-
- /// <summary>
- /// Handle of the affected window, if any.
- /// </summary>
- public IntPtr HWnd
- {
- get { return hWnd; }
- }
-
- /// <summary>
- /// Object ID.
- /// </summary>
- public uint ObjectID
- {
- get { return idObject; }
- }
-
- /// <summary>
- /// Child ID.
- /// </summary>
- public uint ChildID
- {
- get { return idChild; }
- }
-
- /// <summary>
- /// The thread that generated this event.
- /// </summary>
- public uint Thread
- {
- get { return dwEventThread; }
- }
-
- /// <summary>
- /// Time in milliseconds when the event was generated.
- /// </summary>
- public uint Time
- {
- get { return dwmsEventTime; }
- }
-
- /// <summary>
- /// The accessible object related to this event.
- /// </summary>
- public SystemAccessibleObject AccessibleObject
- {
- get
- {
- return AccessibleEventListener.GetAccessibleObject(this);
- }
- }
- }
-
- /// <summary>
- /// This enumeration lists known accessible event types.
- /// </summary>
- public enum AccessibleEventType
- {
- /// <summary>
- /// Sent when a sound is played. Currently nothing is generating this, we
- /// are going to be cleaning up the SOUNDSENTRY feature in the control panel
- /// and will use this at that time. Applications implementing WinEvents
- /// are perfectly welcome to use it. Clients of IAccessible* will simply
- /// turn around and get back a non-visual object that describes the sound.
- /// </summary>
- EVENT_SYSTEM_SOUND = 0x0001,
-
- /// <summary>
- /// Sent when an alert needs to be given to the user. MessageBoxes generate
- /// alerts for example.
- /// </summary>
- EVENT_SYSTEM_ALERT = 0x0002,
-
- /// <summary>
- /// Sent when the foreground (active) window changes, even if it is changing
- /// to another window in the same thread as the previous one.
- /// </summary>
- EVENT_SYSTEM_FOREGROUND = 0x0003,
-
- /// <summary>
- /// Sent when entering into and leaving from menu mode (system, app bar, and
- /// track popups).
- /// </summary>
- EVENT_SYSTEM_MENUSTART = 0x0004,
-
- /// <summary>
- /// Sent when entering into and leaving from menu mode (system, app bar, and
- /// track popups).
- /// </summary>
- EVENT_SYSTEM_MENUEND = 0x0005,
-
- /// <summary>
- /// Sent when a menu popup comes up and just before it is taken down. Note
- /// that for a call to TrackPopupMenu(), a client will see EVENT_SYSTEM_MENUSTART
- /// followed almost immediately by EVENT_SYSTEM_MENUPOPUPSTART for the popup
- /// being shown.
- /// </summary>
- EVENT_SYSTEM_MENUPOPUPSTART = 0x0006,
-
- /// <summary>
- /// Sent when a menu popup comes up and just before it is taken down. Note
- /// that for a call to TrackPopupMenu(), a client will see EVENT_SYSTEM_MENUSTART
- /// followed almost immediately by EVENT_SYSTEM_MENUPOPUPSTART for the popup
- /// being shown.
- /// </summary>
- EVENT_SYSTEM_MENUPOPUPEND = 0x0007,
-
-
- /// <summary>
- /// Sent when a window takes the capture and releases the capture.
- /// </summary>
- EVENT_SYSTEM_CAPTURESTART = 0x0008,
-
- /// <summary>
- /// Sent when a window takes the capture and releases the capture.
- /// </summary>
- EVENT_SYSTEM_CAPTUREEND = 0x0009,
-
- /// <summary>
- /// Sent when a window enters and leaves move-size dragging mode.
- /// </summary>
- EVENT_SYSTEM_MOVESIZESTART = 0x000A,
-
- /// <summary>
- /// Sent when a window enters and leaves move-size dragging mode.
- /// </summary>
- EVENT_SYSTEM_MOVESIZEEND = 0x000B,
-
- /// <summary>
- /// Sent when a window enters and leaves context sensitive help mode.
- /// </summary>
- EVENT_SYSTEM_CONTEXTHELPSTART = 0x000C,
-
- /// <summary>
- /// Sent when a window enters and leaves context sensitive help mode.
- /// </summary>
- EVENT_SYSTEM_CONTEXTHELPEND = 0x000D,
-
- /// <summary>
- /// Sent when a window enters and leaves drag drop mode. Note that it is up
- /// to apps and OLE to generate this, since the system doesn't know. Like
- /// EVENT_SYSTEM_SOUND, it will be a while before this is prevalent.
- /// </summary>
- EVENT_SYSTEM_DRAGDROPSTART = 0x000E,
-
- /// <summary>
- /// Sent when a window enters and leaves drag drop mode. Note that it is up
- /// to apps and OLE to generate this, since the system doesn't know. Like
- /// EVENT_SYSTEM_SOUND, it will be a while before this is prevalent.
- /// </summary>
- EVENT_SYSTEM_DRAGDROPEND = 0x000F,
-
- /// <summary>
- /// Sent when a dialog comes up and just before it goes away.
- /// </summary>
- EVENT_SYSTEM_DIALOGSTART = 0x0010,
-
- /// <summary>
- /// Sent when a dialog comes up and just before it goes away.
- /// </summary>
- EVENT_SYSTEM_DIALOGEND = 0x0011,
-
- /// <summary>
- /// Sent when beginning and ending the tracking of a scrollbar in a window,
- /// and also for scrollbar controls.
- /// </summary>
- EVENT_SYSTEM_SCROLLINGSTART = 0x0012,
-
- /// <summary>
- /// Sent when beginning and ending the tracking of a scrollbar in a window,
- /// and also for scrollbar controls.
- /// </summary>
- EVENT_SYSTEM_SCROLLINGEND = 0x0013,
-
- /// <summary>
- /// Sent when beginning and ending alt-tab mode with the switch window.
- /// </summary>
- EVENT_SYSTEM_SWITCHSTART = 0x0014,
-
- /// <summary>
- /// Sent when beginning and ending alt-tab mode with the switch window.
- /// </summary>
- EVENT_SYSTEM_SWITCHEND = 0x0015,
-
- /// <summary>
- /// Sent when a window minimizes.
- /// </summary>
- EVENT_SYSTEM_MINIMIZESTART = 0x0016,
-
- /// <summary>
- /// Sent just before a window restores.
- /// </summary>
- EVENT_SYSTEM_MINIMIZEEND = 0x0017,
-
- /// <summary>
- /// hwnd + ID + idChild is created item
- /// </summary>
- EVENT_OBJECT_CREATE = 0x8000,
-
- /// <summary>
- /// hwnd + ID + idChild is destroyed item
- /// </summary>
- EVENT_OBJECT_DESTROY = 0x8001,
-
- /// <summary>
- /// hwnd + ID + idChild is shown item
- /// </summary>
- EVENT_OBJECT_SHOW = 0x8002,
-
- /// <summary>
- /// hwnd + ID + idChild is hidden item
- /// </summary>
- EVENT_OBJECT_HIDE = 0x8003,
-
- /// <summary>
- /// hwnd + ID + idChild is parent of zordering children
- /// </summary>
- ...
[truncated message content] |