Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / UIAutomation / 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 : preid 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. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Class used to track context menus appearing // // History: // 3/23/2004 : preid 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
- TraceSection.cs
- InvalidateEvent.cs
- DataTemplateKey.cs
- HTTPRemotingHandler.cs
- Propagator.Evaluator.cs
- ObfuscateAssemblyAttribute.cs
- WeakKeyDictionary.cs
- IssuanceLicense.cs
- MeasureItemEvent.cs
- EntityDataSourceState.cs
- RowUpdatedEventArgs.cs
- WinEventWrap.cs
- PathSegmentCollection.cs
- CSharpCodeProvider.cs
- DependencyObjectCodeDomSerializer.cs
- ArithmeticException.cs
- PropertyChangingEventArgs.cs
- TreeView.cs
- InvokeMethodDesigner.xaml.cs
- ByeMessageApril2005.cs
- VirtualizingPanel.cs
- DefaultParameterValueAttribute.cs
- WebPartsPersonalizationAuthorization.cs
- LinqDataSourceSelectEventArgs.cs
- AuthenticatingEventArgs.cs
- CatalogPart.cs
- CoreSwitches.cs
- ManipulationDeltaEventArgs.cs
- BeginStoryboard.cs
- QilXmlWriter.cs
- PropertyConverter.cs
- XmlDomTextWriter.cs
- DropShadowEffect.cs
- StringSorter.cs
- ResourceReader.cs
- figurelengthconverter.cs
- Selector.cs
- ImmutableCollection.cs
- GroupItem.cs
- DataRecord.cs
- GlyphRunDrawing.cs
- MouseWheelEventArgs.cs
- XXXOnTypeBuilderInstantiation.cs
- XmlUtf8RawTextWriter.cs
- ParserExtension.cs
- ILGenerator.cs
- InvalidAsynchronousStateException.cs
- InstanceNameConverter.cs
- DependentTransaction.cs
- ContextMenuAutomationPeer.cs
- DataGridViewTextBoxColumn.cs
- EntityDataSourceDesignerHelper.cs
- Publisher.cs
- ParseHttpDate.cs
- FixedSOMPageConstructor.cs
- Tracking.cs
- HttpRuntimeSection.cs
- HotSpotCollection.cs
- TagPrefixAttribute.cs
- MetadataPropertyCollection.cs
- HtmlTitle.cs
- HostUtils.cs
- BaseCollection.cs
- ApplicationFileParser.cs
- AdapterSwitches.cs
- FileUtil.cs
- GatewayDefinition.cs
- SchemaImporterExtensionElement.cs
- TransformerInfoCollection.cs
- CommonXSendMessage.cs
- BuilderPropertyEntry.cs
- GeneralTransform3D.cs
- TemplateBindingExtension.cs
- DBSqlParserTable.cs
- ListView.cs
- Helpers.cs
- AppDomainFactory.cs
- TemplatedAdorner.cs
- BitmapCacheBrush.cs
- BCryptHashAlgorithm.cs
- _DisconnectOverlappedAsyncResult.cs
- sapiproxy.cs
- WorkflowTransactionOptions.cs
- Int32Converter.cs
- BinaryMessageEncoder.cs
- ServiceHostingEnvironment.cs
- DependencyPropertyHelper.cs
- ContentFileHelper.cs
- SendKeys.cs
- SmiMetaData.cs
- NavigationService.cs
- CategoryEditor.cs
- UnsafeNativeMethods.cs
- DocumentSequenceHighlightLayer.cs
- BuildProvider.cs
- LocalIdKeyIdentifierClause.cs
- WindowsStartMenu.cs
- CodeDirectiveCollection.cs
- CompilationAssemblyInstallComponent.cs
- WorkflowHostingEndpoint.cs