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;
///
///
///
/// 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
- GeneralTransform3DCollection.cs
- ToolTipService.cs
- DesignerSerializerAttribute.cs
- graph.cs
- XslVisitor.cs
- DbConnectionHelper.cs
- RuleSettings.cs
- CustomAttributeBuilder.cs
- String.cs
- NullRuntimeConfig.cs
- UriSectionData.cs
- ToolStripSplitButton.cs
- ContextMenu.cs
- CodeAssignStatement.cs
- HiddenFieldPageStatePersister.cs
- GradientBrush.cs
- PerformanceCounterPermission.cs
- BeginStoryboard.cs
- ActivityCodeDomSerializationManager.cs
- AttributeSetAction.cs
- ColorPalette.cs
- DataContractFormatAttribute.cs
- ValuePatternIdentifiers.cs
- SqlRowUpdatedEvent.cs
- MouseActionValueSerializer.cs
- ItemList.cs
- PeerNameRecord.cs
- ScaleTransform3D.cs
- SimpleRecyclingCache.cs
- WSDualHttpSecurityElement.cs
- AsymmetricSignatureFormatter.cs
- ResolveNameEventArgs.cs
- BulletChrome.cs
- DateTimeUtil.cs
- SizeAnimationBase.cs
- LeaseManager.cs
- JoinElimination.cs
- IPipelineRuntime.cs
- HttpListener.cs
- RSAPKCS1KeyExchangeFormatter.cs
- Int16KeyFrameCollection.cs
- StylusButton.cs
- NumericUpDown.cs
- AsyncStreamReader.cs
- pingexception.cs
- SqlClientPermission.cs
- FontInfo.cs
- WindowsListViewScroll.cs
- keycontainerpermission.cs
- CompareValidator.cs
- Aggregates.cs
- JsonXmlDataContract.cs
- DES.cs
- XmlnsDefinitionAttribute.cs
- CodeTypeOfExpression.cs
- WinEventQueueItem.cs
- TextViewSelectionProcessor.cs
- DisplayMemberTemplateSelector.cs
- ExecutionContext.cs
- SqlInternalConnectionTds.cs
- APCustomTypeDescriptor.cs
- ADConnectionHelper.cs
- ExtendedPropertiesHandler.cs
- PageAdapter.cs
- ActivitySurrogate.cs
- PersonalizablePropertyEntry.cs
- FocusWithinProperty.cs
- DataGridViewComboBoxEditingControl.cs
- Size3DConverter.cs
- UrlEncodedParameterWriter.cs
- ParentQuery.cs
- RegexNode.cs
- TreeNodeStyle.cs
- QuaternionRotation3D.cs
- SafeCoTaskMem.cs
- WebPermission.cs
- InvariantComparer.cs
- X509ChainElement.cs
- ObjectDataSourceSelectingEventArgs.cs
- BoolLiteral.cs
- Simplifier.cs
- Models.cs
- HTTPNotFoundHandler.cs
- CounterSample.cs
- PersonalizationProvider.cs
- ACE.cs
- KeyGestureValueSerializer.cs
- DataGridTableCollection.cs
- CompositeActivityTypeDescriptorProvider.cs
- ServiceObjectContainer.cs
- MultiplexingFormatMapping.cs
- XmlIlVisitor.cs
- SchemaDeclBase.cs
- DataGridViewDataErrorEventArgs.cs
- FixedSOMTableCell.cs
- ActivityDesignerHighlighter.cs
- UnknownWrapper.cs
- XmlImplementation.cs
- BamlTreeNode.cs
- Pen.cs