Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / System / Windows / Input / Win32MouseDevice.cs / 1 / Win32MouseDevice.cs
using System.Diagnostics; using System.Collections; using System.Windows; using System.Windows.Media; using System.Windows.Interop; using System.Windows.Threading; using System.Security; using System.Security.Permissions; using MS.Internal; using MS.Internal.PresentationCore; // SecurityHelper using MS.Win32; // *NativeMethods using System.Runtime.InteropServices; using System; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// The Win32MouseDevice class implements the platform specific /// MouseDevice features for the Win32 platform /// internal sealed class Win32MouseDevice : MouseDevice { ////// /// /// /// ////// Critical - This is code that elevates AND creates the mouse device which /// happens to hold the callback to filter mouse messages /// TreatAsSafe: This constructor handles critical data but does not expose it /// It stores instance but there are demands on the instances. /// [SecurityCritical,SecurityTreatAsSafe] internal Win32MouseDevice(InputManager inputManager) : base(inputManager) { } ////// Gets the current state of the specified button from the device from the underlying system /// /// /// The mouse button to get the state of /// ////// The state of the specified mouse button /// ////// Critical: Makes calls to UnsafeNativeMethods (GetKeyState) /// TreatAsSafe: Only returns the current state of the specified button /// [SecurityCritical,SecurityTreatAsSafe] internal override MouseButtonState GetButtonStateFromSystem(MouseButton mouseButton) { MouseButtonState mouseButtonState = MouseButtonState.Released; // Security Mitigation: do not give out input state if the device is not active. if(IsActive) { int virtualKeyCode = 0; switch( mouseButton ) { case MouseButton.Left: virtualKeyCode = NativeMethods.VK_LBUTTON; break; case MouseButton.Right: virtualKeyCode = NativeMethods.VK_RBUTTON; break; case MouseButton.Middle: virtualKeyCode = NativeMethods.VK_MBUTTON; break; case MouseButton.XButton1: virtualKeyCode = NativeMethods.VK_XBUTTON1; break; case MouseButton.XButton2: virtualKeyCode = NativeMethods.VK_XBUTTON2; break; } mouseButtonState = ( UnsafeNativeMethods.GetKeyState(virtualKeyCode) & 0x8000 ) != 0 ? MouseButtonState.Pressed : MouseButtonState.Released; } return mouseButtonState; } } } // 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
- BasicViewGenerator.cs
- HttpAsyncResult.cs
- DbDataAdapter.cs
- HTMLTextWriter.cs
- SizeFConverter.cs
- SimpleHandlerBuildProvider.cs
- XPathPatternParser.cs
- UriExt.cs
- LinkLabel.cs
- SRGSCompiler.cs
- AuthorizationRule.cs
- _BasicClient.cs
- StringUtil.cs
- TreeBuilder.cs
- SerializationSectionGroup.cs
- HttpProfileGroupBase.cs
- TextRunTypographyProperties.cs
- TreeIterators.cs
- TreePrinter.cs
- ExpressionVisitor.cs
- DebugInfoExpression.cs
- EventSourceCreationData.cs
- Sql8ExpressionRewriter.cs
- Context.cs
- ComplexBindingPropertiesAttribute.cs
- ValidatedControlConverter.cs
- SingleQueryOperator.cs
- Bidi.cs
- ScriptHandlerFactory.cs
- XmlILCommand.cs
- AuthenticatedStream.cs
- BulletDecorator.cs
- UxThemeWrapper.cs
- CqlParserHelpers.cs
- Memoizer.cs
- ResourceWriter.cs
- DataGrid.cs
- ComAdminWrapper.cs
- SoapEnumAttribute.cs
- DispatcherObject.cs
- BlockUIContainer.cs
- ToolStripItemGlyph.cs
- RadioButtonBaseAdapter.cs
- ResourcePart.cs
- DesignerSerializerAttribute.cs
- Operand.cs
- UrlRoutingHandler.cs
- HideDisabledControlAdapter.cs
- ObjectItemCollection.cs
- RegexRunnerFactory.cs
- OrderedHashRepartitionStream.cs
- AppDomainUnloadedException.cs
- NameNode.cs
- IDispatchConstantAttribute.cs
- OleDbCommand.cs
- DesignerForm.cs
- TagNameToTypeMapper.cs
- TypographyProperties.cs
- StyleXamlParser.cs
- FrameworkElementFactoryMarkupObject.cs
- ResourceManager.cs
- AssemblyBuilderData.cs
- XmlWhitespace.cs
- XmlSchemaInclude.cs
- TextTrailingWordEllipsis.cs
- ReachDocumentSequenceSerializerAsync.cs
- ToolBarTray.cs
- ContractInstanceProvider.cs
- SecurityKeyIdentifier.cs
- TempFiles.cs
- Stack.cs
- SlotInfo.cs
- XmlHierarchyData.cs
- XsdDuration.cs
- ProfileParameter.cs
- Int64KeyFrameCollection.cs
- PerformanceCounterLib.cs
- DataGridViewRowHeightInfoNeededEventArgs.cs
- Size3D.cs
- NetCodeGroup.cs
- BehaviorDragDropEventArgs.cs
- ClientRuntimeConfig.cs
- Nullable.cs
- SystemIPInterfaceProperties.cs
- UnmanagedMemoryStream.cs
- VectorAnimation.cs
- DEREncoding.cs
- UserPreferenceChangingEventArgs.cs
- bindurihelper.cs
- ProfileSettings.cs
- SoapExtensionStream.cs
- SecurityPolicySection.cs
- CompositeControl.cs
- UnsettableComboBox.cs
- TextDecorationCollection.cs
- NativeMethods.cs
- Lease.cs
- FormsIdentity.cs
- IntegerFacetDescriptionElement.cs
- GregorianCalendar.cs