Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / UIAutomationClient / MS / Internal / Automation / MenuTracker.cs / 1305600 / 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpHandler.cs
- DataGridViewLinkCell.cs
- BinaryObjectWriter.cs
- BitVec.cs
- CqlLexerHelpers.cs
- OLEDB_Enum.cs
- RegistrationServices.cs
- XamlClipboardData.cs
- CultureNotFoundException.cs
- VerificationAttribute.cs
- WindowAutomationPeer.cs
- PersonalizationState.cs
- SortQuery.cs
- DynamicILGenerator.cs
- FileDialog.cs
- GroupItemAutomationPeer.cs
- CellLabel.cs
- UIElementCollection.cs
- ImageConverter.cs
- iisPickupDirectory.cs
- log.cs
- SqlAliasesReferenced.cs
- RemoteAsymmetricSignatureFormatter.cs
- FunctionParameter.cs
- PresentationTraceSources.cs
- XmlElementAttribute.cs
- TraceXPathNavigator.cs
- TreeView.cs
- Propagator.JoinPropagator.cs
- SerializationInfoEnumerator.cs
- mediaeventargs.cs
- SystemIPGlobalProperties.cs
- CompilerState.cs
- FilterElement.cs
- RtfControls.cs
- ImagingCache.cs
- DragStartedEventArgs.cs
- TickBar.cs
- TextContainerHelper.cs
- DataGridColumn.cs
- SqlDataSourceCache.cs
- OdbcConnection.cs
- TypeForwardedToAttribute.cs
- ConfigurationStrings.cs
- DetailsViewUpdatedEventArgs.cs
- UIElement3DAutomationPeer.cs
- DataServiceQueryException.cs
- UserMapPath.cs
- QueuePathDialog.cs
- PnrpPermission.cs
- NonVisualControlAttribute.cs
- RectangleF.cs
- SamlConstants.cs
- MobileControlDesigner.cs
- GlobalizationSection.cs
- PenContexts.cs
- SchemaCompiler.cs
- TextParagraphCache.cs
- ParentControlDesigner.cs
- ArgumentException.cs
- DynamicValueConverter.cs
- DataView.cs
- X509Certificate.cs
- Int32CollectionConverter.cs
- RegisteredScript.cs
- HostSecurityManager.cs
- EntityDescriptor.cs
- GacUtil.cs
- ListView.cs
- ManagementException.cs
- WebPartDisplayModeEventArgs.cs
- SqlTriggerAttribute.cs
- SignatureToken.cs
- XmlWrappingWriter.cs
- DrawItemEvent.cs
- Bidi.cs
- LassoSelectionBehavior.cs
- ProxyWebPartManager.cs
- NameNode.cs
- FormViewDeletedEventArgs.cs
- ConfigurationProviderException.cs
- TextWriter.cs
- SimpleTableProvider.cs
- JapaneseLunisolarCalendar.cs
- CopyNodeSetAction.cs
- OleDbWrapper.cs
- WebBodyFormatMessageProperty.cs
- GeneralTransform3D.cs
- AlphabeticalEnumConverter.cs
- DiffuseMaterial.cs
- Int16.cs
- ConfigurationLocation.cs
- SapiGrammar.cs
- PathFigureCollectionValueSerializer.cs
- SoapElementAttribute.cs
- RealizationDrawingContextWalker.cs
- FramingEncoders.cs
- VisualStates.cs
- TagNameToTypeMapper.cs
- MultitargetUtil.cs