Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / AccessibleTech / longhorn / Automation / UIAutomationClient / MS / Internal / Automation / BoundingRectTracker.cs / 1 / BoundingRectTracker.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Class used to send BoundingRect changes for hwnds // // History: // 06/17/2003 : [....] Ported to WCP // //--------------------------------------------------------------------------- using System; using System.Windows; using System.Windows.Automation; using System.Runtime.InteropServices; using System.ComponentModel; using MS.Win32; namespace MS.Internal.Automation { // BoundingRectTracker - Class used to send BoundingRect changes for hwnds internal class BoundingRectTracker : WinEventWrap { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors internal BoundingRectTracker() : base(new int[]{NativeMethods.EVENT_OBJECT_LOCATIONCHANGE, NativeMethods.EVENT_OBJECT_HIDE}) { // Intentionally not setting the callback for the base WinEventWrap since the WinEventProc override // in this class calls RaiseEventInThisClientOnly to actually raise the event to the client. } #endregion Constructors //------------------------------------------------------ // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal override void WinEventProc(int eventId, IntPtr hwnd, int idObject, int idChild, uint eventTime) { // Filter... send an event for hwnd only if ( hwnd == IntPtr.Zero || idObject != UnsafeNativeMethods.OBJID_WINDOW ) return; switch (eventId) { case NativeMethods.EVENT_OBJECT_HIDE: OnHide(hwnd, idObject, idChild); break; case NativeMethods.EVENT_OBJECT_LOCATIONCHANGE: OnLocationChange(hwnd, idObject, idChild); break; } } #endregion Internal Methods //------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods private void OnHide(IntPtr hwnd, int idObject, int idChild) { // Clear last hwnd/rect variables (stop looking for dups) _lastHwnd = hwnd; _lastRect = _emptyRect; } private void OnLocationChange(IntPtr hwnd, int idObject, int idChild) { // Filter... send events for visible hwnds only if (!SafeNativeMethods.IsWindowVisible(NativeMethods.HWND.Cast( hwnd ))) return; HandleBoundingRectChange(hwnd); } private void HandleBoundingRectChange(IntPtr hwnd) { NativeMethods.HWND nativeHwnd = NativeMethods.HWND.Cast( hwnd ); NativeMethods.RECT rc32 = new NativeMethods.RECT(0,0,0,0); // if GetWindwRect fails, most likely the nativeHwnd is an invalid window, so just return. if (!Misc.GetWindowRect(nativeHwnd, out rc32)) { return; } // Filter... avoid duplicate events if (hwnd == _lastHwnd && Compare( rc32, _lastRect )) { return; } AutomationElement rawEl = AutomationElement.FromHandle(hwnd); // // AutomationPropertyChangedEventArgs e = new AutomationPropertyChangedEventArgs( AutomationElement.BoundingRectangleProperty, Rect.Empty, new Rect (rc32.left, rc32.top, rc32.right - rc32.left, rc32.bottom - rc32.top)); // ClientEventManager.RaiseEventInThisClientOnly(AutomationElement.AutomationPropertyChangedEvent, rawEl, e); // save the last hwnd/rect for filtering out duplicates _lastHwnd = hwnd; _lastRect = rc32; } // private static bool Compare( NativeMethods.RECT rc1, NativeMethods.RECT rc2 ) { return rc1.left == rc2.left && rc1.top == rc2.top && rc1.right == rc2.right && rc1.bottom == rc2.bottom; } #endregion Private Methods //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private static NativeMethods.RECT _emptyRect = new NativeMethods.RECT(0,0,0,0); private NativeMethods.RECT _lastRect; // keep track of last location private IntPtr _lastHwnd; // and hwnd for dup checking #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TextDecorationCollection.cs
- IisTraceListener.cs
- IsolatedStorage.cs
- ApplicationServiceHelper.cs
- Screen.cs
- PrtCap_Public.cs
- LinkLabelLinkClickedEvent.cs
- NativeCppClassAttribute.cs
- ActiveDocumentEvent.cs
- PostBackOptions.cs
- Color.cs
- ProviderSettingsCollection.cs
- SystemIPInterfaceStatistics.cs
- DataControlFieldHeaderCell.cs
- ConfigXmlElement.cs
- RegexCode.cs
- SoapSchemaMember.cs
- WebBrowserUriTypeConverter.cs
- SQLBytesStorage.cs
- XmlMapping.cs
- QueryAccessibilityHelpEvent.cs
- DocComment.cs
- precedingquery.cs
- ConvertEvent.cs
- Memoizer.cs
- ObjectHandle.cs
- XPathParser.cs
- PrintPreviewDialog.cs
- SqlFunctions.cs
- CommandLineParser.cs
- Transform3D.cs
- HttpInputStream.cs
- XmlEncApr2001.cs
- _NegotiateClient.cs
- GridViewRow.cs
- StrokeCollection.cs
- StylusOverProperty.cs
- ComboBoxItem.cs
- ProfileParameter.cs
- ProcessingInstructionAction.cs
- DataSourceControlBuilder.cs
- Site.cs
- SystemIcmpV4Statistics.cs
- UmAlQuraCalendar.cs
- MarginsConverter.cs
- MailFileEditor.cs
- Typography.cs
- HtmlInputCheckBox.cs
- Pkcs7Signer.cs
- XmlImplementation.cs
- WebPartManagerInternals.cs
- OptionalColumn.cs
- mediapermission.cs
- PartialClassGenerationTaskInternal.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- WizardDesigner.cs
- BoundsDrawingContextWalker.cs
- DataGridViewCellCollection.cs
- ObjectQuery.cs
- WebSysDefaultValueAttribute.cs
- MaterialGroup.cs
- DataGridCellAutomationPeer.cs
- Serializer.cs
- TextParagraph.cs
- SpotLight.cs
- LineBreakRecord.cs
- TextElementCollection.cs
- InheritanceAttribute.cs
- BamlBinaryReader.cs
- FlowDocumentReader.cs
- TimerEventSubscriptionCollection.cs
- FormViewDeletedEventArgs.cs
- TextChange.cs
- OpenTypeLayout.cs
- ListViewTableCell.cs
- Renderer.cs
- HtmlInputImage.cs
- ErrorLog.cs
- FlowPosition.cs
- TryCatchDesigner.xaml.cs
- ProgressBar.cs
- RadioButtonRenderer.cs
- SimpleApplicationHost.cs
- AsyncStreamReader.cs
- ListViewInsertedEventArgs.cs
- XmlSerializationGeneratedCode.cs
- AssociationSetEnd.cs
- InternalControlCollection.cs
- Function.cs
- AttachedPropertiesService.cs
- GradientBrush.cs
- UInt16.cs
- CommandValueSerializer.cs
- UnknownBitmapDecoder.cs
- TextEditorMouse.cs
- PersonalizationProvider.cs
- SQLBytesStorage.cs
- XmlHierarchyData.cs
- prefixendpointaddressmessagefiltertable.cs
- DllNotFoundException.cs