Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- AxHost.cs
- InstanceContextManager.cs
- Clock.cs
- StrokeCollection2.cs
- ChameleonKey.cs
- SecurityUtils.cs
- CodeDOMProvider.cs
- SkinBuilder.cs
- BaseCodePageEncoding.cs
- QilInvokeEarlyBound.cs
- PeerNameRegistration.cs
- CompilerCollection.cs
- CodeTypeDeclarationCollection.cs
- WindowsGrip.cs
- SizeConverter.cs
- PrivilegeNotHeldException.cs
- WinCategoryAttribute.cs
- ApplicationServiceManager.cs
- SoapHeaders.cs
- IdnMapping.cs
- BooleanProjectedSlot.cs
- WizardStepBase.cs
- OpenFileDialog.cs
- HandleScope.cs
- GcSettings.cs
- Speller.cs
- XmlCDATASection.cs
- Point4DValueSerializer.cs
- TextOutput.cs
- FormCollection.cs
- ScrollProperties.cs
- DirectoryInfo.cs
- WebServiceData.cs
- MsmqTransportReceiveParameters.cs
- AssemblyName.cs
- CompiledQuery.cs
- DiffuseMaterial.cs
- ImageMap.cs
- ActiveDocumentEvent.cs
- FieldToken.cs
- FixedFlowMap.cs
- ResourceReferenceExpressionConverter.cs
- ImageDrawing.cs
- HGlobalSafeHandle.cs
- BindingWorker.cs
- XhtmlBasicCommandAdapter.cs
- RestHandlerFactory.cs
- ResourcePart.cs
- IssuedTokenClientElement.cs
- HtmlTableRowCollection.cs
- XmlSchemaNotation.cs
- XmlWellformedWriter.cs
- CriticalExceptions.cs
- MeshGeometry3D.cs
- UInt64Converter.cs
- PropertyEmitter.cs
- X509CertificateStore.cs
- NullableFloatSumAggregationOperator.cs
- DbParameterCollectionHelper.cs
- ObjectDataSourceFilteringEventArgs.cs
- Propagator.Evaluator.cs
- SecureEnvironment.cs
- HtmlElementEventArgs.cs
- ListViewGroup.cs
- RepeatBehaviorConverter.cs
- UIElementParaClient.cs
- TemplateXamlTreeBuilder.cs
- LogSwitch.cs
- SrgsRuleRef.cs
- BaseAsyncResult.cs
- PolicyManager.cs
- DataListItemEventArgs.cs
- HtmlInputRadioButton.cs
- EmptyEnumerable.cs
- HttpModuleAction.cs
- DateTimeValueSerializerContext.cs
- DataGridViewCheckBoxCell.cs
- ValidatorAttribute.cs
- ReliableSession.cs
- CompiledQuery.cs
- ClientSponsor.cs
- DataGridSortingEventArgs.cs
- PagePropertiesChangingEventArgs.cs
- OleDbParameter.cs
- TypographyProperties.cs
- AutomationPropertyInfo.cs
- PropertyOverridesDialog.cs
- ChildrenQuery.cs
- Event.cs
- UnsafeNativeMethods.cs
- FixedTextSelectionProcessor.cs
- KeyValueSerializer.cs
- WebEventCodes.cs
- PrinterResolution.cs
- TextBounds.cs
- FormsAuthenticationConfiguration.cs
- ColorTransform.cs
- MulticastDelegate.cs
- InfiniteTimeSpanConverter.cs
- XmlHierarchicalEnumerable.cs