Message.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Permission is hereby granted, free of charge, to any person obtaining
  2. // a copy of this software and associated documentation files (the
  3. // "Software"), to deal in the Software without restriction, including
  4. // without limitation the rights to use, copy, modify, merge, publish,
  5. // distribute, sublicense, and/or sell copies of the Software, and to
  6. // permit persons to whom the Software is furnished to do so, subject to
  7. // the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. // Copyright (c) 2004 Novell, Inc.
  21. //
  22. // Authors:
  23. // Peter Bartok [email protected]
  24. //
  25. //
  26. // $Log: Message.cs,v $
  27. // Revision 1.2 2004/08/11 22:20:59 pbartok
  28. // - Signature fixes
  29. //
  30. // Revision 1.1 2004/07/09 05:21:25 pbartok
  31. // - Initial check-in
  32. //
  33. //
  34. // COMPLETE
  35. using System;
  36. using System.Runtime.InteropServices;
  37. using System.Text;
  38. using System.Diagnostics;
  39. namespace System.Windows.Forms {
  40. public struct Message {
  41. private int msg;
  42. private IntPtr hwnd;
  43. private IntPtr lParam;
  44. private IntPtr wParam;
  45. private IntPtr result;
  46. #region Public Instance Properties
  47. public IntPtr HWnd {
  48. get { return hwnd; }
  49. set { hwnd=value; }
  50. }
  51. public IntPtr LParam {
  52. get { return lParam; }
  53. set { lParam=value; }
  54. }
  55. public int Msg {
  56. get { return msg; }
  57. set { msg=value; }
  58. }
  59. public IntPtr Result {
  60. get { return result; }
  61. set { result=value; }
  62. }
  63. public IntPtr WParam {
  64. get { return wParam; }
  65. set { wParam=value; }
  66. }
  67. #endregion // Public Instance Properties
  68. #region Public Static Methods
  69. public static Message Create(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) {
  70. Message new_message = new Message();
  71. new_message.msg=msg;
  72. new_message.hwnd=hWnd;
  73. new_message.wParam=wparam;
  74. new_message.lParam=lparam;
  75. return new_message;
  76. }
  77. #endregion // Public Static Methods
  78. #region Public Instance Methods
  79. public override bool Equals(object o) {
  80. if (!(o is Message)) {
  81. return false;
  82. }
  83. return ((this.msg == ((Message)o).msg) &&
  84. (this.hwnd == ((Message)o).hwnd) &&
  85. (this.lParam == ((Message)o).lParam) &&
  86. (this.wParam == ((Message)o).wParam) &&
  87. (this.result == ((Message)o).result));
  88. }
  89. public override int GetHashCode() {
  90. return base.GetHashCode();
  91. }
  92. public object GetLParam(Type cls) {
  93. object o = Marshal.PtrToStructure(this.lParam, cls);
  94. return(o);
  95. }
  96. public override string ToString() {
  97. return String.Format("[{0} {1} {2} {3}]", msg.ToString(), lParam.ToString(), wParam.ToString(), hwnd.ToString());
  98. }
  99. #endregion // Public Instance Methods
  100. }
  101. }