using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace CPF.Windows { public struct Message { 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 Marshal.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; 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() { return "msg=0x" + Convert.ToString(msg, 16) + " hwnd=0x" + Convert.ToString((long)hWnd, 16) + " wparam=0x" + Convert.ToString((long)wparam, 16) + " lparam=0x" + Convert.ToString((long)lparam, 16) + " result=0x" + Convert.ToString((long)result, 16); } } }