Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / 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. 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
- xml.cs
- AnnotationService.cs
- BinaryOperationBinder.cs
- CustomAttributeSerializer.cs
- StylusPoint.cs
- EntityClientCacheEntry.cs
- MessageTransmitTraceRecord.cs
- MobileUserControlDesigner.cs
- DataGridTemplateColumn.cs
- XmlDataSource.cs
- IdnElement.cs
- Debug.cs
- CalendarAutoFormatDialog.cs
- XmlSchemaException.cs
- PropertyMetadata.cs
- GAC.cs
- CodePageEncoding.cs
- AuthenticationModuleElementCollection.cs
- HtmlContainerControl.cs
- listitem.cs
- LocalizableAttribute.cs
- ActiveDesignSurfaceEvent.cs
- TimelineClockCollection.cs
- InvalidOperationException.cs
- WindowsPrincipal.cs
- FileCodeGroup.cs
- TextBoxAutomationPeer.cs
- SQLInt16Storage.cs
- EvidenceTypeDescriptor.cs
- AnimatedTypeHelpers.cs
- ConfigurationElement.cs
- StringCollection.cs
- Environment.cs
- BinaryNode.cs
- FontStyleConverter.cs
- NullRuntimeConfig.cs
- BodyGlyph.cs
- Exceptions.cs
- RIPEMD160.cs
- StorageRoot.cs
- ContractAdapter.cs
- SortedSet.cs
- DbgCompiler.cs
- AnnotationAdorner.cs
- ErrorCodes.cs
- COM2Enum.cs
- ModelVisual3D.cs
- AsyncDataRequest.cs
- Operator.cs
- LazyTextWriterCreator.cs
- InputMethodStateChangeEventArgs.cs
- HostedTransportConfigurationManager.cs
- ActivityDesigner.cs
- RijndaelManagedTransform.cs
- WSHttpBinding.cs
- JsonFormatWriterGenerator.cs
- ResourceExpression.cs
- UnitySerializationHolder.cs
- DefaultPropertyAttribute.cs
- templategroup.cs
- DoubleAnimationUsingKeyFrames.cs
- XmlSchemaGroupRef.cs
- ServiceParser.cs
- FormClosedEvent.cs
- SectionVisual.cs
- TaiwanCalendar.cs
- ReadOnlyCollection.cs
- SelectionPatternIdentifiers.cs
- SoapAttributes.cs
- PasswordBox.cs
- XPathNodeList.cs
- _ProxyRegBlob.cs
- RSAPKCS1KeyExchangeFormatter.cs
- CacheModeValueSerializer.cs
- DataControlFieldHeaderCell.cs
- FormViewDeletedEventArgs.cs
- CellTreeSimplifier.cs
- Random.cs
- ContentElement.cs
- StreamWithDictionary.cs
- Environment.cs
- TableCellCollection.cs
- ToolStripPanelRenderEventArgs.cs
- _ProxyRegBlob.cs
- RegexCompiler.cs
- LockCookie.cs
- AnimationTimeline.cs
- DeflateStream.cs
- StyleBamlTreeBuilder.cs
- Pts.cs
- RuntimeConfigurationRecord.cs
- ReceiveDesigner.xaml.cs
- UIElementParagraph.cs
- XmlDataSourceView.cs
- WindowsFormsHost.cs
- InvalidCastException.cs
- FaultBookmark.cs
- MdbDataFileEditor.cs
- SoapExtension.cs
- NullableConverter.cs