0

In the following class, the attributes of WParam and LParam are IntPtr type, but I do not know the meaning they represent. I found them in the definition of C++. It is rather troublesome. Is there a way to know the above two attributes quickly?

    namespace System.Windows.Forms
    {
        public struct Message
        {
            public int Msg { get; set; }
            public IntPtr WParam { get; set; }
            public IntPtr LParam { get; set; }
            public IntPtr Result { get; set; }
            public static Message Create(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam);
            public override bool Equals(object o);
            public override int GetHashCode();
            public object GetLParam(Type cls);
            public override string ToString();
            public static bool operator ==(Message a, Message b);
            public static bool operator !=(Message a, Message b);
        }
    }
coder
  • 8,346
  • 16
  • 39
  • 53
cnxy
  • 11
  • 3
  • look here: https://stackoverflow.com/a/1148184/9055793 – Raizzen Apr 27 '18 at 08:14
  • 1
    Each message gets to define `WParam` and `LParam` as it sees fit. You won't find *a* definition. You need to inspect individual message types to understand what they represent. – Damien_The_Unbeliever Apr 27 '18 at 08:17
  • The C# class is just copy of the win api structure (C++) https://msdn.microsoft.com/en-us/library/ms644958(VS.85).aspx if you want more information, try reading about winapi – mortb Apr 27 '18 at 08:19
  • E.g. [`WM_MOVE`](https://msdn.microsoft.com/en-us/library/windows/desktop/ms632631(v=vs.85).aspx) doesn't assign any meaning to `WParam` and packs a pair of values into `LParam`. – Damien_The_Unbeliever Apr 27 '18 at 08:20

1 Answers1

1

wParam and lParam have no intrinsic meaning. They're simply "payload" variables that contain the data that each message passes, and their value (or lack thereof) changes for each specific message.

For instance, in the WM_SETTEXT message (which sets a window's text, such as a window's title bar), MSDN gives you this:

wParam: This parameter is not used.

lParam: A pointer to a null-terminated string that is the window text.

While in WM_SHOWWINDOW (which shows/hides a window), docs show this:

wParam:

Indicates whether a window is being shown. If wParam is TRUE, the window is being shown. If wParam is FALSE, the window is being hidden.

lParam

The status of the window being shown. If lParam is zero, the message was sent because of a call to the ShowWindow function; otherwise, lParam is one of the following values.

  • SW_OTHERUNZOOM - 4 - The window is being uncovered because a maximize window was restored or minimized.
  • SW_OTHERZOOM - 2 - The window is being covered by another window that has been maximized.
  • SW_PARENTCLOSING - 1 - The window's owner window is being minimized.
  • SW_PARENTOPENING - 3 - The window's owner window is being restored.

As you can see, there's no standard, fixed meaning. You can't even assume that in messages that carry a window handle (hWnd), it's wParam that will carry it while lParam carries other data. It's purely up to the individual message.

Avner Shahar-Kashtan
  • 14,492
  • 3
  • 37
  • 63