Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / 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
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- XmlProcessingInstruction.cs
- KeyProperty.cs
- XPathMessageFilterElement.cs
- RelatedEnd.cs
- httpserverutility.cs
- XmlExtensionFunction.cs
- DifferencingCollection.cs
- FieldNameLookup.cs
- PublisherMembershipCondition.cs
- LeaseManager.cs
- GeneralTransform.cs
- ILGenerator.cs
- CrossAppDomainChannel.cs
- Oid.cs
- TextBlockAutomationPeer.cs
- PointCollectionConverter.cs
- DocumentReference.cs
- SmiConnection.cs
- Helpers.cs
- HighlightComponent.cs
- CodeAttachEventStatement.cs
- XmlNamedNodeMap.cs
- NameScope.cs
- SubqueryRules.cs
- ObjectView.cs
- WorkItem.cs
- MonthChangedEventArgs.cs
- HttpHandlerActionCollection.cs
- WebPart.cs
- XmlAttributeAttribute.cs
- ParameterToken.cs
- ExpressionValueEditor.cs
- OdbcInfoMessageEvent.cs
- LinkClickEvent.cs
- AllMembershipCondition.cs
- BitmapFrameDecode.cs
- XmlTextWriter.cs
- SourceFileBuildProvider.cs
- SQLGuidStorage.cs
- EdmToObjectNamespaceMap.cs
- BuildProvider.cs
- DataListCommandEventArgs.cs
- TextFormatterContext.cs
- BindStream.cs
- CqlLexerHelpers.cs
- DATA_BLOB.cs
- ToolstripProfessionalRenderer.cs
- PDBReader.cs
- HitTestParameters.cs
- BlobPersonalizationState.cs
- Label.cs
- ObjectDataSource.cs
- LineBreakRecord.cs
- UniqueSet.cs
- XmlSchemaComplexType.cs
- TemplateControl.cs
- ExceptionUtil.cs
- ThumbButtonInfo.cs
- SQLResource.cs
- BaseConfigurationRecord.cs
- SelectionPattern.cs
- DiscoveryInnerClientAdhoc11.cs
- XmlNamespaceManager.cs
- AutomationPropertyInfo.cs
- infer.cs
- ConfigurationPermission.cs
- QilReplaceVisitor.cs
- VoiceObjectToken.cs
- AutoResetEvent.cs
- assemblycache.cs
- PrintingPermission.cs
- Registry.cs
- HtmlTextArea.cs
- ValidatorCollection.cs
- WindowsGraphics2.cs
- Executor.cs
- UnaryNode.cs
- XmlSerializationGeneratedCode.cs
- PointF.cs
- GridPatternIdentifiers.cs
- IListConverters.cs
- TraceSource.cs
- SystemMulticastIPAddressInformation.cs
- CompositeDispatchFormatter.cs
- MasterPageParser.cs
- XmlDomTextWriter.cs
- PeerNameRegistration.cs
- SelectionManager.cs
- DataBoundControlHelper.cs
- StandardCommands.cs
- NumberFunctions.cs
- CodeGenerator.cs
- ValueHandle.cs
- PrinterSettings.cs
- MemoryRecordBuffer.cs
- QuotedPrintableStream.cs
- ProviderBase.cs
- EventProviderTraceListener.cs
- WindowsRichEditRange.cs
- PersistChildrenAttribute.cs