Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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() { // ----URT : 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. // //----------------------------------------------------------------------------- /* */ 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() { // ----URT : 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.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CodeIndexerExpression.cs
- Stack.cs
- ValidationPropertyAttribute.cs
- DatatypeImplementation.cs
- CharStorage.cs
- XmlWrappingReader.cs
- MouseGestureConverter.cs
- PropertyValueChangedEvent.cs
- PhonemeEventArgs.cs
- DBNull.cs
- ToolStripPanel.cs
- Calendar.cs
- GridViewItemAutomationPeer.cs
- ImageResources.Designer.cs
- Evaluator.cs
- Pointer.cs
- AtomParser.cs
- UTF8Encoding.cs
- XmlIlVisitor.cs
- XmlSchemaSet.cs
- TimeSpan.cs
- IconConverter.cs
- RequestResizeEvent.cs
- ScaleTransform3D.cs
- TrackingLocationCollection.cs
- Image.cs
- OracleCommand.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- LayoutSettings.cs
- Byte.cs
- TimeSpanFormat.cs
- PolicyManager.cs
- basemetadatamappingvisitor.cs
- DescendentsWalkerBase.cs
- OrCondition.cs
- SerialPort.cs
- CompoundFileDeflateTransform.cs
- SHA512Cng.cs
- SequentialWorkflowHeaderFooter.cs
- URL.cs
- GridItem.cs
- HandlerMappingMemo.cs
- StylusDevice.cs
- ModelProperty.cs
- DetailsViewUpdatedEventArgs.cs
- DetailsViewUpdatedEventArgs.cs
- ConcurrentStack.cs
- SessionEndedEventArgs.cs
- COM2EnumConverter.cs
- GroupJoinQueryOperator.cs
- QueryableDataSourceEditData.cs
- categoryentry.cs
- WindowsStartMenu.cs
- SmiConnection.cs
- XmlSchemaAttributeGroup.cs
- CryptographicAttribute.cs
- InputBuffer.cs
- VirtualDirectoryMappingCollection.cs
- SrgsElement.cs
- RegexCaptureCollection.cs
- LicenseProviderAttribute.cs
- Debugger.cs
- IApplicationTrustManager.cs
- AdjustableArrowCap.cs
- Vector3DCollectionConverter.cs
- TemplateBamlRecordReader.cs
- Geometry3D.cs
- SplitContainer.cs
- CompressionTransform.cs
- VisualState.cs
- ColorDialog.cs
- BasicHttpBindingElement.cs
- PeerSecurityManager.cs
- TdsEnums.cs
- ErrorTableItemStyle.cs
- LinkButton.cs
- CacheVirtualItemsEvent.cs
- ExpressionValueEditor.cs
- AppLevelCompilationSectionCache.cs
- HtmlShim.cs
- MethodSet.cs
- ResourceDescriptionAttribute.cs
- ContentDisposition.cs
- AnimationException.cs
- Collection.cs
- MetadataSet.cs
- WindowsListViewGroupHelper.cs
- ICspAsymmetricAlgorithm.cs
- HGlobalSafeHandle.cs
- HostingPreferredMapPath.cs
- SeekableReadStream.cs
- XPathDocumentIterator.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- IgnorePropertiesAttribute.cs
- StateManagedCollection.cs
- Connector.xaml.cs
- ConnectionPoint.cs
- ProgressiveCrcCalculatingStream.cs
- DesignerView.xaml.cs
- GradientBrush.cs