Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / Win32MouseDevice.cs / 1305600 / 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
- SafeReadContext.cs
- StateValidator.cs
- ServicePoint.cs
- WebZone.cs
- TextProperties.cs
- CodeConstructor.cs
- XmlILModule.cs
- OleDbCommand.cs
- ContextMarshalException.cs
- Baml2006ReaderContext.cs
- PropertyChangedEventArgs.cs
- AddInStore.cs
- GridViewRow.cs
- RegexGroupCollection.cs
- ZipIOExtraFieldPaddingElement.cs
- _SSPIWrapper.cs
- RuntimeArgument.cs
- DiffuseMaterial.cs
- DataGridViewCellValueEventArgs.cs
- CellParagraph.cs
- StateMachineTimers.cs
- WindowsFormsLinkLabel.cs
- DataGridViewElement.cs
- TargetConverter.cs
- ActiveXSite.cs
- MetadataArtifactLoaderCompositeResource.cs
- XPathNodePointer.cs
- TemplatedAdorner.cs
- XmlWhitespace.cs
- ControlAdapter.cs
- MasterPageCodeDomTreeGenerator.cs
- BinaryUtilClasses.cs
- InvalidComObjectException.cs
- PropertyMappingExceptionEventArgs.cs
- DataObjectEventArgs.cs
- MediaPlayer.cs
- GroupQuery.cs
- RegexCompilationInfo.cs
- LocalizeDesigner.cs
- TextFormatter.cs
- Bitmap.cs
- RowSpanVector.cs
- SctClaimDictionary.cs
- EventRouteFactory.cs
- FormViewInsertEventArgs.cs
- ResXDataNode.cs
- ThousandthOfEmRealDoubles.cs
- PathFigure.cs
- TextShapeableCharacters.cs
- TraceXPathNavigator.cs
- FormViewInsertEventArgs.cs
- GroupJoinQueryOperator.cs
- Ops.cs
- ComponentEvent.cs
- ConstructorExpr.cs
- ListViewContainer.cs
- NewArrayExpression.cs
- DataException.cs
- figurelengthconverter.cs
- DBAsyncResult.cs
- counter.cs
- ImageListStreamer.cs
- followingsibling.cs
- DataSet.cs
- FixedSOMLineCollection.cs
- XmlEncodedRawTextWriter.cs
- VisualStyleInformation.cs
- UnsafeCollabNativeMethods.cs
- CaseKeyBox.ViewModel.cs
- MarkupWriter.cs
- NavigationPropertyAccessor.cs
- SessionState.cs
- CacheVirtualItemsEvent.cs
- SubpageParagraph.cs
- BaseValidatorDesigner.cs
- SoapExtensionImporter.cs
- SingleAnimationBase.cs
- BaseCodeDomTreeGenerator.cs
- TextDocumentView.cs
- CSharpCodeProvider.cs
- QilPatternFactory.cs
- WebPartCloseVerb.cs
- TagPrefixCollection.cs
- ArgIterator.cs
- ClockController.cs
- DataGridPageChangedEventArgs.cs
- ProcessThreadCollection.cs
- PackageStore.cs
- KeyedCollection.cs
- AsyncOperation.cs
- HttpModuleCollection.cs
- DocumentViewerAutomationPeer.cs
- StructuredTypeEmitter.cs
- FileLevelControlBuilderAttribute.cs
- ObjectDataSourceDisposingEventArgs.cs
- ThreadPool.cs
- TrackBarRenderer.cs
- StubHelpers.cs
- XmlSchemaAny.cs
- RegexNode.cs