Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / WinForms / Managed / System / WinForms / Message.cs / 1 / Message.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* */ namespace System.Windows.Forms { using System.Text; using System.Runtime.InteropServices; using System.Runtime.Remoting; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Security; using System.Security.Permissions; using System; using System.Windows.Forms; ////// /// [SecurityPermission(SecurityAction.LinkDemand, Flags=SecurityPermissionFlag.UnmanagedCode)] [SuppressMessage("Microsoft.Security", "CA2108:ReviewDeclarativeSecurityOnValueTypes")] public struct Message { #if DEBUG static TraceSwitch AllWinMessages = new TraceSwitch("AllWinMessages", "Output every received message"); #endif IntPtr hWnd; int msg; IntPtr wparam; IntPtr lparam; IntPtr result; ////// Implements a Windows message. ////// /// public IntPtr HWnd { get { return hWnd; } set { hWnd = value; } } ///Specifies the window handle of the message. ////// /// public int Msg { get { return msg; } set { msg = value; } } ///Specifies the ID number for the message. ////// /// public IntPtr WParam { get { return wparam; } set { wparam = value; } } ///Specifies the ///of the message. /// /// public IntPtr LParam { get { return lparam; } set { lparam = value; } } ///Specifies the ///of the message. /// /// public IntPtr Result { get { return result; } set { result = value; } } ///Specifies the return value of the message. ////// /// public object GetLParam(Type cls) { return UnsafeNativeMethods.PtrToStructure(lparam, cls); } ///Gets the ///value, and converts the value to an object. /// /// public static Message Create(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) { Message m = new Message(); m.hWnd = hWnd; m.msg = msg; m.wparam = wparam; m.lparam = lparam; m.result = IntPtr.Zero; #if DEBUG if(AllWinMessages.TraceVerbose) { Debug.WriteLine(m.ToString()); } #endif return m; } ///Creates a new ///object. public override bool Equals(object o) { if (!(o is Message)) { return false; } Message m = (Message)o; return hWnd == m.hWnd && msg == m.msg && wparam == m.wparam && lparam == m.lparam && result == m.result; } public static bool operator !=(Message a, Message b) { return !a.Equals(b); } public static bool operator ==(Message a, Message b) { return a.Equals(b); } /// public override int GetHashCode() { return (int)hWnd << 4 | msg; } /// /// /// /// public override string ToString() { // ASSURT : 151574. Link Demand on System.Windows.Forms.Message // fails to protect overriden methods. bool unrestricted = false; try { IntSecurity.UnmanagedCode.Demand(); unrestricted = true; } catch (SecurityException) { // eat the exception. } if (unrestricted) { return MessageDecoder.ToString(this); } else { return base.ToString(); } } } } // 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
- XamlFilter.cs
- GridViewAutomationPeer.cs
- BitmapEffectGroup.cs
- UnmanagedBitmapWrapper.cs
- SharedStatics.cs
- CodeArrayIndexerExpression.cs
- OracleConnectionFactory.cs
- TraceUtility.cs
- UnsignedPublishLicense.cs
- Task.cs
- _AcceptOverlappedAsyncResult.cs
- SoapSchemaImporter.cs
- XPathChildIterator.cs
- RectAnimationUsingKeyFrames.cs
- XmlUTF8TextWriter.cs
- DrawingVisual.cs
- WpfWebRequestHelper.cs
- AddInToken.cs
- XmlSerializerNamespaces.cs
- WebUtility.cs
- MimeFormReflector.cs
- PointHitTestResult.cs
- TcpTransportSecurity.cs
- GregorianCalendarHelper.cs
- StrongNameUtility.cs
- BuildManagerHost.cs
- DataGridViewColumnConverter.cs
- TextPointerBase.cs
- ViewValidator.cs
- DataGridPagerStyle.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- Compilation.cs
- ConstraintConverter.cs
- AuthorizationRuleCollection.cs
- httpapplicationstate.cs
- MimeBasePart.cs
- LayoutDump.cs
- AsyncCompletedEventArgs.cs
- StylusPointProperty.cs
- MemoryStream.cs
- BooleanToSelectiveScrollingOrientationConverter.cs
- ObfuscateAssemblyAttribute.cs
- ToolStripItemEventArgs.cs
- StringReader.cs
- Compiler.cs
- ValueHandle.cs
- BindingExpressionBase.cs
- QilList.cs
- AlphabeticalEnumConverter.cs
- BinaryFormatterWriter.cs
- FunctionDescription.cs
- _NativeSSPI.cs
- QueryRewriter.cs
- RoutedEventValueSerializer.cs
- ConnectionProviderAttribute.cs
- Accessible.cs
- WebDescriptionAttribute.cs
- AQNBuilder.cs
- FlowNode.cs
- EdmComplexPropertyAttribute.cs
- UserPreferenceChangedEventArgs.cs
- VariableElement.cs
- ToolStripArrowRenderEventArgs.cs
- RelatedImageListAttribute.cs
- ScopelessEnumAttribute.cs
- UnmanagedBitmapWrapper.cs
- DataSourceProvider.cs
- XmlQueryCardinality.cs
- ApplyTemplatesAction.cs
- Dump.cs
- ScalarType.cs
- CompressionTransform.cs
- ReferenceService.cs
- SocketException.cs
- Command.cs
- MatrixCamera.cs
- CompositeActivityValidator.cs
- Converter.cs
- nulltextnavigator.cs
- XmlSchemaInferenceException.cs
- EnumBuilder.cs
- Reference.cs
- SqlClientFactory.cs
- EventLogPermissionEntry.cs
- DbConvert.cs
- CodeAccessPermission.cs
- WindowInteractionStateTracker.cs
- PeerCollaboration.cs
- EtwTrace.cs
- GiveFeedbackEvent.cs
- IndexExpression.cs
- TreeView.cs
- ProfileEventArgs.cs
- X509ServiceCertificateAuthenticationElement.cs
- ExpressionBuilderContext.cs
- WebBrowserDocumentCompletedEventHandler.cs
- IisHelper.cs
- DataControlButton.cs
- EntityContainerRelationshipSet.cs
- DesignerHelpers.cs