Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / 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
- _SpnDictionary.cs
- RbTree.cs
- RegistryDataKey.cs
- XmlUrlResolver.cs
- BitHelper.cs
- PrivilegeNotHeldException.cs
- PolicyLevel.cs
- UnsafeNativeMethods.cs
- _emptywebproxy.cs
- FrameworkContextData.cs
- DummyDataSource.cs
- COM2TypeInfoProcessor.cs
- FilteredSchemaElementLookUpTable.cs
- BitmapFrameDecode.cs
- SchemaEntity.cs
- WebPart.cs
- PtsPage.cs
- EntityClassGenerator.cs
- HuffModule.cs
- LifetimeServices.cs
- mansign.cs
- SqlTriggerAttribute.cs
- dbenumerator.cs
- ElementNotAvailableException.cs
- SimpleWorkerRequest.cs
- XamlVector3DCollectionSerializer.cs
- TrackingServices.cs
- FontWeights.cs
- OdbcConnectionFactory.cs
- ExpressionHelper.cs
- Asn1IntegerConverter.cs
- QueryCacheKey.cs
- TokenizerHelper.cs
- SQLInt16.cs
- XmlQuerySequence.cs
- DESCryptoServiceProvider.cs
- PerformanceCounterPermissionEntry.cs
- IntegerValidator.cs
- TextParagraphView.cs
- TextEncodedRawTextWriter.cs
- SpeechDetectedEventArgs.cs
- ContainerUIElement3D.cs
- LoginView.cs
- AnonymousIdentificationSection.cs
- CustomWebEventKey.cs
- GridViewItemAutomationPeer.cs
- SlotInfo.cs
- TableRowGroup.cs
- BufferModesCollection.cs
- AssertSection.cs
- AuthenticationSection.cs
- CompiledELinqQueryState.cs
- EntityClientCacheEntry.cs
- recordstatefactory.cs
- SchemaObjectWriter.cs
- TreeNodeBinding.cs
- BinaryKeyIdentifierClause.cs
- SigningCredentials.cs
- controlskin.cs
- SessionEndingEventArgs.cs
- SrgsRulesCollection.cs
- AsymmetricCryptoHandle.cs
- OrderByQueryOptionExpression.cs
- MemberExpression.cs
- FixedTextContainer.cs
- CompositeFontParser.cs
- Rights.cs
- X509SecurityTokenProvider.cs
- OptimizedTemplateContent.cs
- RightNameExpirationInfoPair.cs
- ObjectStateEntry.cs
- SqlRewriteScalarSubqueries.cs
- CodeNamespaceCollection.cs
- RtfControls.cs
- ErrorProvider.cs
- AbstractExpressions.cs
- DataGridViewRowPrePaintEventArgs.cs
- OptionalColumn.cs
- ServiceChannelProxy.cs
- InitializationEventAttribute.cs
- TimeIntervalCollection.cs
- BaseValidator.cs
- CodeMemberProperty.cs
- FixedStringLookup.cs
- InstanceData.cs
- DropShadowEffect.cs
- DataContractJsonSerializer.cs
- SystemColors.cs
- ObjectListCommandCollection.cs
- ArglessEventHandlerProxy.cs
- XXXOnTypeBuilderInstantiation.cs
- ConfigurationValue.cs
- PrePrepareMethodAttribute.cs
- Renderer.cs
- ToolStripContainer.cs
- OracleLob.cs
- PeerNodeAddress.cs
- AppSettingsReader.cs
- NavigatingCancelEventArgs.cs
- _CommandStream.cs