Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / UIAutomation / UIAutomationClient / MS / Internal / Automation / WindowShowOrOpenTracker.cs / 1 / 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. //---------------------------------------------------------------------------- // //// 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
- NonBatchDirectoryCompiler.cs
- ELinqQueryState.cs
- IncrementalHitTester.cs
- xmlglyphRunInfo.cs
- WebPartConnectionsDisconnectVerb.cs
- RepeatButtonAutomationPeer.cs
- ListSortDescriptionCollection.cs
- ResourceAssociationTypeEnd.cs
- _ServiceNameStore.cs
- JulianCalendar.cs
- ObjectDataSourceFilteringEventArgs.cs
- HMACSHA384.cs
- SignatureGenerator.cs
- ApplicationBuildProvider.cs
- KnownAssembliesSet.cs
- MailAddressParser.cs
- codemethodreferenceexpression.cs
- XmlResolver.cs
- CodeBinaryOperatorExpression.cs
- X509CertificateChain.cs
- ApplicationGesture.cs
- InputProcessorProfiles.cs
- RectangleGeometry.cs
- HttpConfigurationContext.cs
- TypeUnloadedException.cs
- ReferenceEqualityComparer.cs
- ParameterDataSourceExpression.cs
- ZoneMembershipCondition.cs
- _RequestCacheProtocol.cs
- EnumConverter.cs
- FloaterParaClient.cs
- RegexFCD.cs
- XamlInt32CollectionSerializer.cs
- base64Transforms.cs
- ScriptComponentDescriptor.cs
- AxisAngleRotation3D.cs
- GACMembershipCondition.cs
- ExpressionBuilder.cs
- EnterpriseServicesHelper.cs
- Tracking.cs
- CodeAttributeArgumentCollection.cs
- CompoundFileIOPermission.cs
- OrderPreservingMergeHelper.cs
- MapPathBasedVirtualPathProvider.cs
- OutputScopeManager.cs
- SqlClientFactory.cs
- WpfKnownMemberInvoker.cs
- SessionStateSection.cs
- ThreadExceptionDialog.cs
- DecimalAnimationUsingKeyFrames.cs
- LinkGrep.cs
- PrePostDescendentsWalker.cs
- RelOps.cs
- ColorConvertedBitmapExtension.cs
- SqlLiftWhereClauses.cs
- MetadataException.cs
- PageStatePersister.cs
- IncomingWebRequestContext.cs
- ApplicationServiceManager.cs
- _ProxyChain.cs
- StrokeFIndices.cs
- KeyboardNavigation.cs
- DependencyPropertyConverter.cs
- DataBindingExpressionBuilder.cs
- ScopeCollection.cs
- XmlAnyElementAttributes.cs
- SqlCaseSimplifier.cs
- BinaryConverter.cs
- TypeToArgumentTypeConverter.cs
- SessionPageStateSection.cs
- RawStylusInputCustomDataList.cs
- DiscreteKeyFrames.cs
- TypeConverterHelper.cs
- ComContractElementCollection.cs
- GridViewRowEventArgs.cs
- TextEditorCopyPaste.cs
- XPathNodePointer.cs
- OutOfProcStateClientManager.cs
- CodeDOMUtility.cs
- ToolStripSplitButton.cs
- ContextStack.cs
- JoinTreeSlot.cs
- FileSystemWatcher.cs
- VerificationAttribute.cs
- DataColumn.cs
- RenderContext.cs
- SmiMetaData.cs
- SynchronizingStream.cs
- DataRowView.cs
- XmlObjectSerializer.cs
- SqlSelectStatement.cs
- Compiler.cs
- XmlSchemaSimpleContentExtension.cs
- DataRowCollection.cs
- EntityDataSourceConfigureObjectContext.cs
- AliasGenerator.cs
- contentDescriptor.cs
- SecurityTokenAuthenticator.cs
- CodeNamespaceImportCollection.cs
- UnsignedPublishLicense.cs