Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / UIAutomationClient / MS / Internal / Automation / WindowShowOrOpenTracker.cs / 1305600 / WindowShowOrOpenTracker.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Class used to track new UI appearing and make sure any events // are propogated to that new UI. // // History: // 06/17/2003 : BrendanM Ported to WCP // 11/20/2003 : Micw renamed NewUITracker.cs to WindowShowOrOpenTracker.cs // //--------------------------------------------------------------------------- using System; using System.Globalization; using System.Text; using System.Windows.Automation; using System.Diagnostics; using MS.Win32; namespace MS.Internal.Automation { // WindowShowOrOpenTracker - Class used to track new UI appearing and make sure any events // are propogated to that new UI. internal delegate void WindowShowOrOpenHandler( IntPtr hwnd, AutomationElement rawEl ); // Class used to track new UI appearing and make sure any events // are propogated to that new UI. internal class WindowShowOrOpenTracker : WinEventWrap { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors internal WindowShowOrOpenTracker(WindowShowOrOpenHandler newUIHandler) : base(new int[] {NativeMethods.EventObjectUIFragmentCreate, NativeMethods.EVENT_OBJECT_CREATE, NativeMethods.EVENT_OBJECT_SHOW}) { AddCallback(newUIHandler); } #endregion Constructors //------------------------------------------------------ // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal override void WinEventProc(int eventId, IntPtr hwnd, int idObject, int idChild, uint eventTime) { // ignore any event not pertaining directly to the window if (idObject != UnsafeNativeMethods.OBJID_WINDOW) return; // Ignore if this is a bogus hwnd (shouldn't happen) if (hwnd == IntPtr.Zero) return; NativeMethods.HWND nativeHwnd = NativeMethods.HWND.Cast( hwnd ); // Ignore windows that have been destroyed if (! SafeNativeMethods.IsWindow( nativeHwnd )) return; // Ignore invisible windows (IsWindowVisible takes the hwnd ancestor // visibility into account) if (! SafeNativeMethods.IsWindowVisible( nativeHwnd )) return; if (eventId == NativeMethods.EVENT_OBJECT_CREATE) { // Ignore WCP hwnd creates; we get eventId EventObjectUIFragmentCreate for those // string str = ProxyManager.GetClassName(nativeHwnd); if (String.Compare(str, 0, _wcpClassName, 0, _wcpClassName.Length, StringComparison.OrdinalIgnoreCase) == 0) return; } AutomationElement rawEl = AutomationElement.FromHandle( hwnd ); // Do the notify. Note that this handler is used to notify client-side UIAutomation providers of windows // being destroyed or hidden. The delegate called here is itself protected by a lock. This delegate may // call out to proxies but also calls ClientEventManager.RaiseEventInThisClientOnly which properly // queues the actual callout to client code. object [] handlers = GetHandlers(); Debug.Assert(handlers.Length <= 1, "handlers.Length"); if (handlers.Length > 0) ((WindowShowOrOpenHandler)handlers[0])( hwnd, rawEl ); } #endregion Internal Methods //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ #region Private Fields static readonly string _wcpClassName = "HwndWrapper"; #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
- SliderAutomationPeer.cs
- XmlLinkedNode.cs
- CommonObjectSecurity.cs
- TypeInitializationException.cs
- CurrentChangingEventManager.cs
- TreeNodeStyleCollection.cs
- HttpModulesSection.cs
- GridErrorDlg.cs
- TableProviderWrapper.cs
- AffineTransform3D.cs
- DialogWindow.cs
- UnsafeNativeMethods.cs
- HtmlImage.cs
- ArraySet.cs
- NameValueSectionHandler.cs
- AssemblyUtil.cs
- WeakRefEnumerator.cs
- ItemContainerGenerator.cs
- ScriptHandlerFactory.cs
- ComponentCollection.cs
- EventProviderBase.cs
- cache.cs
- DataSourceSelectArguments.cs
- ContentPropertyAttribute.cs
- SmtpDigestAuthenticationModule.cs
- BitmapEffectInput.cs
- SettingsPropertyValue.cs
- ScaleTransform.cs
- HMAC.cs
- KeyValuePairs.cs
- StylusPointDescription.cs
- UnsafeNativeMethodsPenimc.cs
- IsolatedStorageSecurityState.cs
- XPathQilFactory.cs
- RoutedEventValueSerializer.cs
- XPathSelfQuery.cs
- BatchParser.cs
- SoapEnumAttribute.cs
- DataViewManager.cs
- FrameworkReadOnlyPropertyMetadata.cs
- SmiSettersStream.cs
- SqlCacheDependency.cs
- MenuCommand.cs
- TemplateAction.cs
- XPathDocumentBuilder.cs
- ImpersonationContext.cs
- Match.cs
- TextWriter.cs
- Ref.cs
- TabControlCancelEvent.cs
- TreeNodeStyleCollectionEditor.cs
- WinFormsSpinner.cs
- SortExpressionBuilder.cs
- PermissionSet.cs
- DropDownButton.cs
- AutomationProperty.cs
- StringBuilder.cs
- ConversionHelper.cs
- RepeatBehaviorConverter.cs
- BuildDependencySet.cs
- ClientRolePrincipal.cs
- CopyNodeSetAction.cs
- DataGridViewComboBoxCell.cs
- Activity.cs
- SByte.cs
- ItemCollection.cs
- TypeForwardedFromAttribute.cs
- ModelPerspective.cs
- BitmapEffect.cs
- IsolationInterop.cs
- RawAppCommandInputReport.cs
- ModelTreeManager.cs
- NetworkStream.cs
- UdpDuplexChannel.cs
- WindowsListBox.cs
- Material.cs
- ManagedWndProcTracker.cs
- AlphabeticalEnumConverter.cs
- TrackingQueryElement.cs
- NamespaceMapping.cs
- FaultHandlingFilter.cs
- DataBoundLiteralControl.cs
- EntityStoreSchemaFilterEntry.cs
- FieldMetadata.cs
- PageHandlerFactory.cs
- ResourceDisplayNameAttribute.cs
- SvcMapFile.cs
- Popup.cs
- XmlSerializableWriter.cs
- ImageAutomationPeer.cs
- IndentedWriter.cs
- SourceSwitch.cs
- SQLString.cs
- BrowserCapabilitiesFactoryBase.cs
- GlyphRunDrawing.cs
- DynamicRenderer.cs
- WSFederationHttpBindingCollectionElement.cs
- FaultReasonText.cs
- SelectionPatternIdentifiers.cs
- ResourceIDHelper.cs