Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / UIAutomation / Win32Providers / MS / Internal / AutomationProxies / WindowsToolbarItemAsMenuItem.cs / 1 / 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
- FloatSumAggregationOperator.cs
- UpdateCommandGenerator.cs
- FileCodeGroup.cs
- Label.cs
- OrderedDictionary.cs
- CompilationRelaxations.cs
- PiiTraceSource.cs
- EntityStoreSchemaGenerator.cs
- CalculatedColumn.cs
- TraceLevelStore.cs
- diagnosticsswitches.cs
- ToolStrip.cs
- ListMarkerSourceInfo.cs
- DesigntimeLicenseContextSerializer.cs
- CatalogZone.cs
- XamlPointCollectionSerializer.cs
- LeftCellWrapper.cs
- ComplexBindingPropertiesAttribute.cs
- MultipartContentParser.cs
- RequestBringIntoViewEventArgs.cs
- MatrixValueSerializer.cs
- CompositionTarget.cs
- OleDbMetaDataFactory.cs
- IgnoreSectionHandler.cs
- SectionUpdates.cs
- CompiledRegexRunnerFactory.cs
- InputProcessorProfilesLoader.cs
- MatrixAnimationUsingKeyFrames.cs
- InputLanguageProfileNotifySink.cs
- TimeManager.cs
- SiteMembershipCondition.cs
- AmbientLight.cs
- ClassData.cs
- Debug.cs
- AstNode.cs
- XmlLanguageConverter.cs
- AppDomainProtocolHandler.cs
- ExtensionWindowHeader.cs
- BindingGroup.cs
- XmlLinkedNode.cs
- ToolStripSplitButton.cs
- SamlAuthorizationDecisionStatement.cs
- ControllableStoryboardAction.cs
- TraceHwndHost.cs
- ServiceDiscoveryElement.cs
- NamespaceDecl.cs
- PreparingEnlistment.cs
- XamlFigureLengthSerializer.cs
- DiscoveryService.cs
- AnnouncementInnerClient11.cs
- CrossContextChannel.cs
- EntitySetBase.cs
- BitmapEffectInput.cs
- LinkConverter.cs
- DataObjectCopyingEventArgs.cs
- RichTextBoxDesigner.cs
- EntityStoreSchemaGenerator.cs
- FontFaceLayoutInfo.cs
- MarkedHighlightComponent.cs
- PageHandlerFactory.cs
- ResolveDuplex11AsyncResult.cs
- securestring.cs
- DocumentPage.cs
- InternalConfigHost.cs
- Matrix.cs
- StringAttributeCollection.cs
- _LocalDataStoreMgr.cs
- HttpServerUtilityBase.cs
- SplashScreen.cs
- TypeInitializationException.cs
- DateTimePicker.cs
- CalendarDataBindingHandler.cs
- DataSourceCache.cs
- Accessors.cs
- PrintController.cs
- sitestring.cs
- SchemaImporterExtensionElementCollection.cs
- PageBuildProvider.cs
- MemberPath.cs
- MemberPath.cs
- COSERVERINFO.cs
- TabItemAutomationPeer.cs
- BrowserTree.cs
- SyntaxCheck.cs
- WebPartTransformer.cs
- VariableAction.cs
- EntityDataSource.cs
- Vector3DCollectionConverter.cs
- DataGridViewCellLinkedList.cs
- OleDbRowUpdatedEvent.cs
- ContentDisposition.cs
- TypeValidationEventArgs.cs
- SchemaEntity.cs
- sqlser.cs
- RTLAwareMessageBox.cs
- TransformerConfigurationWizardBase.cs
- IList.cs
- XmlDataCollection.cs
- DbConnectionPool.cs
- XslCompiledTransform.cs