Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / Message.cs / 1305376 / 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;
///
///
///
/// Implements a Windows message.
///
[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;
///
///
/// Specifies the window handle of the message.
///
public IntPtr HWnd {
get { return hWnd; }
set { hWnd = value; }
}
///
///
/// Specifies the ID number for the message.
///
public int Msg {
get { return msg; }
set { msg = value; }
}
///
///
/// Specifies the of 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 return value of the message.
///
public IntPtr Result {
get { return result; }
set { result = value; }
}
///
///
/// Gets the value, and converts the value to an object.
///
public object GetLParam(Type cls) {
return UnsafeNativeMethods.PtrToStructure(lparam, cls);
}
///
///
/// Creates a new 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;
}
///
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;
///
///
///
/// Implements a Windows message.
///
[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;
///
///
/// Specifies the window handle of the message.
///
public IntPtr HWnd {
get { return hWnd; }
set { hWnd = value; }
}
///
///
/// Specifies the ID number for the message.
///
public int Msg {
get { return msg; }
set { msg = value; }
}
///
///
/// Specifies the of 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 return value of the message.
///
public IntPtr Result {
get { return result; }
set { result = value; }
}
///
///
/// Gets the value, and converts the value to an object.
///
public object GetLParam(Type cls) {
return UnsafeNativeMethods.PtrToStructure(lparam, cls);
}
///
///
/// Creates a new 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;
}
///
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
- CompModSwitches.cs
- COM2PropertyDescriptor.cs
- MdiWindowListItemConverter.cs
- TargetControlTypeAttribute.cs
- RadioButton.cs
- BamlStream.cs
- ChangePassword.cs
- TemplateManager.cs
- Zone.cs
- XhtmlBasicTextViewAdapter.cs
- ImageFormatConverter.cs
- StringHandle.cs
- TextEndOfParagraph.cs
- ResourceProviderFactory.cs
- XPathParser.cs
- StylusPointProperty.cs
- DoubleLinkListEnumerator.cs
- PropertyMappingExceptionEventArgs.cs
- SEHException.cs
- ResourceContainer.cs
- RegexTree.cs
- Table.cs
- StreamWithDictionary.cs
- FocusTracker.cs
- WSFederationHttpBinding.cs
- GridView.cs
- IssuedTokenParametersElement.cs
- FeatureSupport.cs
- AttachedPropertiesService.cs
- SourceInterpreter.cs
- StorageInfo.cs
- EditableTreeList.cs
- AVElementHelper.cs
- SchemaComplexType.cs
- GridViewDeleteEventArgs.cs
- ProcessModelSection.cs
- TemplateBaseAction.cs
- ControlPaint.cs
- GenericEnumerator.cs
- UndirectedGraph.cs
- InputProcessorProfilesLoader.cs
- StrokeCollection.cs
- SubMenuStyle.cs
- VisualTreeUtils.cs
- newitemfactory.cs
- WorkItem.cs
- XamlSerializerUtil.cs
- ExternalException.cs
- IOThreadTimer.cs
- ECDiffieHellmanPublicKey.cs
- AdCreatedEventArgs.cs
- ObjectHandle.cs
- PropertyChangingEventArgs.cs
- StringSource.cs
- QuaternionRotation3D.cs
- ConnectionStringSettingsCollection.cs
- BitmapSourceSafeMILHandle.cs
- FileRecordSequenceCompletedAsyncResult.cs
- TraceHandlerErrorFormatter.cs
- WebFaultClientMessageInspector.cs
- DependencyPropertyValueSerializer.cs
- PropertyPathWorker.cs
- BinaryFormatterWriter.cs
- DecimalConstantAttribute.cs
- ScriptManagerProxy.cs
- OracleColumn.cs
- HelpInfo.cs
- MetadataUtilsSmi.cs
- DescendantQuery.cs
- _ScatterGatherBuffers.cs
- DataGrid.cs
- ConfigurationValues.cs
- SHA256Managed.cs
- mansign.cs
- InternalConfigHost.cs
- Normalization.cs
- PageContent.cs
- AsyncStreamReader.cs
- AttachedPropertyBrowsableAttribute.cs
- IntSecurity.cs
- SchemaImporter.cs
- MergeEnumerator.cs
- SqlFacetAttribute.cs
- PropertyInformation.cs
- NetCodeGroup.cs
- UserNamePasswordValidator.cs
- SmiXetterAccessMap.cs
- ForEachAction.cs
- ProjectedSlot.cs
- IntegerValidator.cs
- HtmlInputSubmit.cs
- ObjectQueryExecutionPlan.cs
- StylusEditingBehavior.cs
- Polyline.cs
- DescendantBaseQuery.cs
- AutomationPatternInfo.cs
- OdbcCommand.cs
- WinFormsSpinner.cs
- OverflowException.cs
- CorrelationManager.cs