Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / UIAutomation / Win32Providers / MS / Internal / AutomationProxies / WindowsToolbarItemAsMenuItem.cs / 1305600 / WindowsToolbarItemAsMenuItem.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: Some applications implement menus with toolbars. This proxy // will used the IAccessible to expose these toolbar items as // menu items. This proxy is derived from ToolbarItem since // the underlying control really is a toolbar and ToolbarItem // knows how to communicate with a toolbars to get information for // toolbar items already. // // History: // 01/31/2005 : [....] Created //--------------------------------------------------------------------------- using System; using System.Windows.Automation; using MS.Win32; namespace MS.Internal.AutomationProxies { class ToolbarItemAsMenuItem : ToolbarItem { // ----------------------------------------------------- // // Constructors // // ----------------------------------------------------- #region Constructors internal ToolbarItemAsMenuItem(IntPtr hwnd, ProxyFragment parent, int item, int idCommand, Accessible acc) : base(hwnd, parent, item, idCommand) { _acc = acc; // Set the control type based on the IAccessible role. AccessibleRole role = acc.Role; if (role == AccessibleRole.MenuItem) { _cControlType = ControlType.MenuItem; } else { System.Diagnostics.Debug.Assert(false, "Unexpected role " + role); } // MenuItems are by default KeyboardFocusable. _fIsKeyboardFocusable = true; } #endregion // ------------------------------------------------------ // // Patterns Implementation // // ----------------------------------------------------- #region ProxySimple Interface // Returns a pattern interface if supported. internal override object GetPatternProvider (AutomationPattern iid) { // Treate these toolbar items as menuitems and only support Invoke or Expand/Collapse patterns. // Invoke Pattern needs to be supported when the item has no children. When the item does have // children it needs to support ExpandCollapse Pattern. // Check if button is a separator if (IsSeparator()) { return null; } // Check if button is disabled if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONENABLED, new IntPtr(_idCommand), IntPtr.Zero) == 0) { return null; } // Check if button is hidden if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONHIDDEN, new IntPtr(_idCommand), IntPtr.Zero) != 0) { return null; } // if (iid == InvokePattern.Pattern) { // button is enabled and not hidden and not a separator return this; } // return null; } // Process all the Element Properties internal override object GetElementProperty(AutomationProperty idProp) { if (idProp == AutomationElement.HasKeyboardFocusProperty) { return IsFocused(); } return base.GetElementProperty(idProp); } #endregion // ------------------------------------------------------ // // Private Fields // // ------------------------------------------------------ #region Private Fields Accessible _acc; #endregion } } // 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: Some applications implement menus with toolbars. This proxy // will used the IAccessible to expose these toolbar items as // menu items. This proxy is derived from ToolbarItem since // the underlying control really is a toolbar and ToolbarItem // knows how to communicate with a toolbars to get information for // toolbar items already. // // History: // 01/31/2005 : [....] Created //--------------------------------------------------------------------------- using System; using System.Windows.Automation; using MS.Win32; namespace MS.Internal.AutomationProxies { class ToolbarItemAsMenuItem : ToolbarItem { // ----------------------------------------------------- // // Constructors // // ----------------------------------------------------- #region Constructors internal ToolbarItemAsMenuItem(IntPtr hwnd, ProxyFragment parent, int item, int idCommand, Accessible acc) : base(hwnd, parent, item, idCommand) { _acc = acc; // Set the control type based on the IAccessible role. AccessibleRole role = acc.Role; if (role == AccessibleRole.MenuItem) { _cControlType = ControlType.MenuItem; } else { System.Diagnostics.Debug.Assert(false, "Unexpected role " + role); } // MenuItems are by default KeyboardFocusable. _fIsKeyboardFocusable = true; } #endregion // ------------------------------------------------------ // // Patterns Implementation // // ----------------------------------------------------- #region ProxySimple Interface // Returns a pattern interface if supported. internal override object GetPatternProvider (AutomationPattern iid) { // Treate these toolbar items as menuitems and only support Invoke or Expand/Collapse patterns. // Invoke Pattern needs to be supported when the item has no children. When the item does have // children it needs to support ExpandCollapse Pattern. // Check if button is a separator if (IsSeparator()) { return null; } // Check if button is disabled if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONENABLED, new IntPtr(_idCommand), IntPtr.Zero) == 0) { return null; } // Check if button is hidden if (Misc.ProxySendMessageInt(_hwnd, NativeMethods.TB_ISBUTTONHIDDEN, new IntPtr(_idCommand), IntPtr.Zero) != 0) { return null; } // if (iid == InvokePattern.Pattern) { // button is enabled and not hidden and not a separator return this; } // return null; } // Process all the Element Properties internal override object GetElementProperty(AutomationProperty idProp) { if (idProp == AutomationElement.HasKeyboardFocusProperty) { return IsFocused(); } return base.GetElementProperty(idProp); } #endregion // ------------------------------------------------------ // // Private Fields // // ------------------------------------------------------ #region Private Fields Accessible _acc; #endregion } } // 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
- CellLabel.cs
- UrlPath.cs
- BasicDesignerLoader.cs
- HebrewNumber.cs
- Drawing.cs
- DataGridViewColumnStateChangedEventArgs.cs
- QilReference.cs
- CollectionsUtil.cs
- DataGridCommandEventArgs.cs
- ListViewInsertEventArgs.cs
- ContentIterators.cs
- CommonXSendMessage.cs
- KeyConverter.cs
- HebrewNumber.cs
- SqlConnection.cs
- RadioButtonStandardAdapter.cs
- BaseParagraph.cs
- Pointer.cs
- RoutedEventHandlerInfo.cs
- counter.cs
- MultipartContentParser.cs
- AssertFilter.cs
- ModelItemDictionaryImpl.cs
- ConfigWriter.cs
- ToolStripOverflow.cs
- ComNativeDescriptor.cs
- ComponentEditorPage.cs
- IResourceProvider.cs
- PropertyMetadata.cs
- TransformGroup.cs
- AudienceUriMode.cs
- DocumentGrid.cs
- ContainerParaClient.cs
- XmlSchemaExporter.cs
- SizeAnimationBase.cs
- HandlerMappingMemo.cs
- TypographyProperties.cs
- AnnotationObservableCollection.cs
- ProcessHostFactoryHelper.cs
- TextOutput.cs
- CounterSetInstanceCounterDataSet.cs
- VBCodeProvider.cs
- AvtEvent.cs
- SchemaImporter.cs
- InputLangChangeEvent.cs
- Transform.cs
- BindingExpressionUncommonField.cs
- DefaultProfileManager.cs
- TextDecorationCollectionConverter.cs
- BinaryParser.cs
- HandleRef.cs
- ReturnEventArgs.cs
- PrtCap_Public.cs
- XmlNamespaceMappingCollection.cs
- Canvas.cs
- Brush.cs
- _AutoWebProxyScriptEngine.cs
- RuntimeResourceSet.cs
- InlinedLocationReference.cs
- DateTimeConstantAttribute.cs
- BamlBinaryWriter.cs
- FtpCachePolicyElement.cs
- QilFactory.cs
- OdbcStatementHandle.cs
- EntityDataSourceWrapper.cs
- RSACryptoServiceProvider.cs
- linebase.cs
- ColorContext.cs
- ModelProperty.cs
- Tool.cs
- HandoffBehavior.cs
- counter.cs
- TraceProvider.cs
- HttpCapabilitiesSectionHandler.cs
- _PooledStream.cs
- TypeHelpers.cs
- Pair.cs
- TabletDevice.cs
- ProxyElement.cs
- RelativeSource.cs
- Partitioner.cs
- StorageAssociationSetMapping.cs
- AnimationClock.cs
- RecommendedAsConfigurableAttribute.cs
- SafeNativeMethods.cs
- StickyNoteContentControl.cs
- TouchEventArgs.cs
- PanelStyle.cs
- XmlIterators.cs
- TextServicesContext.cs
- InvokeProviderWrapper.cs
- TypeValidationEventArgs.cs
- HtmlControl.cs
- StorageBasedPackageProperties.cs
- RSACryptoServiceProvider.cs
- MaskDesignerDialog.cs
- WebCategoryAttribute.cs
- DataObjectSettingDataEventArgs.cs
- WS2007FederationHttpBinding.cs
- TextRange.cs