Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / AccessibleTech / longhorn / Automation / UIAutomationClient / MS / Internal / Automation / MenuTracker.cs / 1 / MenuTracker.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Class used to track context menus appearing // // History: // 3/23/2004 : [....] Created // //--------------------------------------------------------------------------- using System; using System.Text; using System.Windows.Automation; using System.Diagnostics; using MS.Win32; namespace MS.Internal.Automation { internal delegate void MenuHandler( AutomationElement rawEl, bool menuHasOpened ); // MenuOpened - Class used to track context menus appearing internal class MenuTracker : WinEventWrap { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors internal MenuTracker(MenuHandler newHandler) : base(new int[] {NativeMethods.EVENT_SYSTEM_MENUPOPUPSTART, NativeMethods.EVENT_SYSTEM_MENUPOPUPEND}) { AddCallback(newHandler); } #endregion Constructors //------------------------------------------------------ // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal override void WinEventProc(int eventId, IntPtr hwnd, int idObject, int idChild, uint eventTime) { AutomationElement rawEl = null; bool menuHasOpened = eventId == NativeMethods.EVENT_SYSTEM_MENUPOPUPSTART; // Only create a raw element wrapper if the menu has popped up. Send a // null element for menu closed (the element isn't available anymore). // if( menuHasOpened ) { // Ignore if this is a bogus hwnd (shouldn't happen) if( hwnd == IntPtr.Zero ) return; NativeMethods.HWND nativeHwnd = NativeMethods.HWND.Cast( hwnd ); if( !SafeNativeMethods.IsWindow( nativeHwnd ) ) return; // Filter... send events for visible hwnds only if( !SafeNativeMethods.IsWindowVisible( nativeHwnd ) ) return; rawEl = AutomationElement.FromHandle( hwnd ); } // Do callback. This handler is called due to a WinEvent on the client. The handler // is going to hand off the work of calling out to the client code to another thread // via a queue so it is safe to do this callback w/in the lock. object [] handlers = GetHandlers(); Debug.Assert(handlers.Length <= 1, "handlers.Length"); if( handlers.Length > 0 ) ( ( MenuHandler )handlers[0] )( rawEl, menuHasOpened ); } #endregion Internal Methods } } // 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
- ResourceDictionary.cs
- BrushMappingModeValidation.cs
- AnnotationComponentManager.cs
- ListView.cs
- DesignConnection.cs
- QuadraticBezierSegment.cs
- MetadataReference.cs
- LookupBindingPropertiesAttribute.cs
- SvcMapFile.cs
- SourceLineInfo.cs
- VScrollProperties.cs
- TypeGeneratedEventArgs.cs
- StackSpiller.Temps.cs
- SourceChangedEventArgs.cs
- CustomTrackingQuery.cs
- DBConcurrencyException.cs
- TCEAdapterGenerator.cs
- DirectoryObjectSecurity.cs
- SqlProvider.cs
- CodeTryCatchFinallyStatement.cs
- ByteAnimationBase.cs
- WeakReferenceEnumerator.cs
- PersonalizationProviderCollection.cs
- TimeSpanConverter.cs
- Attributes.cs
- AnnotationDocumentPaginator.cs
- SystemNetworkInterface.cs
- ExpressionTextBox.xaml.cs
- ArgumentDesigner.xaml.cs
- ObjectListCommandsPage.cs
- ImageButton.cs
- ConstraintManager.cs
- TextRunCache.cs
- WebPartsPersonalizationAuthorization.cs
- GetPageNumberCompletedEventArgs.cs
- BamlTreeUpdater.cs
- AutomationPatternInfo.cs
- AuthStoreRoleProvider.cs
- DesignerSerializerAttribute.cs
- Menu.cs
- ChtmlLinkAdapter.cs
- XmlElementList.cs
- PackagePart.cs
- SystemNetHelpers.cs
- ValidatingPropertiesEventArgs.cs
- ObjectStorage.cs
- ModelItemCollectionImpl.cs
- TextTreeTextBlock.cs
- LinearKeyFrames.cs
- FormViewUpdatedEventArgs.cs
- ThreadSafeList.cs
- SecurityResources.cs
- PeerCredentialElement.cs
- DateTimeParse.cs
- ColorConvertedBitmap.cs
- GeneralTransform3DTo2D.cs
- ContractNamespaceAttribute.cs
- Vector3DAnimationBase.cs
- ProfileGroupSettings.cs
- HttpProfileBase.cs
- MissingFieldException.cs
- TextBoxBase.cs
- baseaxisquery.cs
- UdpContractFilterBehavior.cs
- DataBoundLiteralControl.cs
- FormCollection.cs
- CTreeGenerator.cs
- DataGridViewCellFormattingEventArgs.cs
- Msmq.cs
- OSEnvironmentHelper.cs
- RewritingProcessor.cs
- TextTabProperties.cs
- CollectionBuilder.cs
- PieceNameHelper.cs
- RegexNode.cs
- Win32Interop.cs
- xdrvalidator.cs
- Content.cs
- MessageQueueEnumerator.cs
- NativeMethods.cs
- CodeGotoStatement.cs
- WorkflowTransactionOptions.cs
- WebDescriptionAttribute.cs
- DataGridHeaderBorder.cs
- DatatypeImplementation.cs
- HttpProtocolReflector.cs
- HierarchicalDataSourceControl.cs
- DataGridRelationshipRow.cs
- PointAnimationBase.cs
- MultiTouchSystemGestureLogic.cs
- AjaxFrameworkAssemblyAttribute.cs
- ActiveXSerializer.cs
- BreakRecordTable.cs
- OdbcFactory.cs
- Internal.cs
- TransactionState.cs
- DeclarationUpdate.cs
- XLinq.cs
- ColorConvertedBitmapExtension.cs
- TransformerConfigurationWizardBase.cs