Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / AccessibleTech / longhorn / Automation / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- oledbmetadatacolumnnames.cs
- WorkflowIdleElement.cs
- QueryConverter.cs
- DateTimeOffsetConverter.cs
- FrameworkReadOnlyPropertyMetadata.cs
- WebPartVerb.cs
- SendActivityDesignerTheme.cs
- HMACRIPEMD160.cs
- ViewSimplifier.cs
- MenuItem.cs
- FormViewUpdatedEventArgs.cs
- X509CertificateTrustedIssuerElement.cs
- TextTreeRootTextBlock.cs
- Application.cs
- OleDbWrapper.cs
- FloatUtil.cs
- ValueCollectionParameterReader.cs
- CultureSpecificStringDictionary.cs
- PasswordRecovery.cs
- SafeEventHandle.cs
- QueryPageSettingsEventArgs.cs
- X509Extension.cs
- Overlapped.cs
- CursorConverter.cs
- WindowShowOrOpenTracker.cs
- XmlSerializationWriter.cs
- BaseParaClient.cs
- ErrorCodes.cs
- PreservationFileReader.cs
- XPathPatternParser.cs
- XmlSchemaSimpleContent.cs
- CodeExporter.cs
- SiteMapHierarchicalDataSourceView.cs
- ActivityWithResult.cs
- ObjectContextServiceProvider.cs
- CoTaskMemHandle.cs
- _BufferOffsetSize.cs
- BaseTemplateCodeDomTreeGenerator.cs
- ScriptingJsonSerializationSection.cs
- storepermissionattribute.cs
- SystemIcmpV4Statistics.cs
- ToolStripLocationCancelEventArgs.cs
- Statements.cs
- Cursors.cs
- DataGridViewCellFormattingEventArgs.cs
- CancellationTokenSource.cs
- HttpSocketManager.cs
- DataGridTextBoxColumn.cs
- StructuralType.cs
- SqlUdtInfo.cs
- WebColorConverter.cs
- MessageQueuePermission.cs
- FileLogRecordHeader.cs
- Overlapped.cs
- Site.cs
- ObjectTag.cs
- _NtlmClient.cs
- GroupItem.cs
- Array.cs
- LineBreakRecord.cs
- CngKeyBlobFormat.cs
- XmlDictionaryReaderQuotas.cs
- TraceContext.cs
- SizeAnimationBase.cs
- TextReturnReader.cs
- UriTemplateClientFormatter.cs
- ServiceThrottle.cs
- WaitForChangedResult.cs
- NullableFloatSumAggregationOperator.cs
- DesigntimeLicenseContext.cs
- MapPathBasedVirtualPathProvider.cs
- ToolStripGripRenderEventArgs.cs
- sitestring.cs
- StorageMappingItemLoader.cs
- StorageRoot.cs
- MailWebEventProvider.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- DataGridViewCellValidatingEventArgs.cs
- ColumnResizeUndoUnit.cs
- XPathNavigatorKeyComparer.cs
- Encoder.cs
- TextContainerHelper.cs
- GenericTextProperties.cs
- MsmqIntegrationValidationBehavior.cs
- SourceElementsCollection.cs
- WindowsScrollBarBits.cs
- PrimitiveSchema.cs
- SafeWaitHandle.cs
- precedingquery.cs
- Rect.cs
- SchemaImporter.cs
- CodeAccessPermission.cs
- Vertex.cs
- FlowLayoutPanel.cs
- Properties.cs
- RotationValidation.cs
- IResourceProvider.cs
- StrongNamePublicKeyBlob.cs
- SubMenuStyleCollection.cs
- RemotingAttributes.cs