From 4c85c898ce7b338bcd126a0225ce990c2b19d3c4 Mon Sep 17 00:00:00 2001 From: dahall Date: Fri, 25 Dec 2020 20:40:00 -0700 Subject: [PATCH] Added constructor for MSG struct --- PInvoke/Shared/WinUser/MSG.cs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/PInvoke/Shared/WinUser/MSG.cs b/PInvoke/Shared/WinUser/MSG.cs index 736c3de7..8c9ff483 100644 --- a/PInvoke/Shared/WinUser/MSG.cs +++ b/PInvoke/Shared/WinUser/MSG.cs @@ -4,7 +4,9 @@ using System.Runtime.InteropServices; namespace Vanara.PInvoke { /// Contains message information from a thread's message queue. - [PInvokeData("winuser.h")] + // https://docs.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-msg typedef struct tagMSG { HWND hwnd; UINT message; WPARAM + // wParam; LPARAM lParam; DWORD time; POINT pt; DWORD lPrivate; } MSG, *PMSG, *NPMSG, *LPMSG; + [PInvokeData("winuser.h", MSDNShortId = "NS:winuser.tagMSG")] [StructLayout(LayoutKind.Sequential)] public struct MSG { @@ -30,5 +32,26 @@ namespace Vanara.PInvoke /// The vertical cursor position, in screen coordinates, when the message was posted. public int pt_y; + + /// Initializes a new instance of the struct. + /// + /// A handle to the window whose window procedure receives the message. This member is NULL when the message is a thread message. + /// + /// The message identifier. Applications can only use the low word; the high word is reserved by the system. + /// Additional information about the message. The exact meaning depends on the value of the message member. + /// Additional information about the message. The exact meaning depends on the value of the message member. + /// The horizontal cursor position, in screen coordinates, when the message was posted. + /// The vertical cursor position, in screen coordinates, when the message was posted. + /// The time at which the message was posted. + public MSG(HWND hwnd, uint msg, IntPtr wParam, IntPtr lParam, int pt_x = default, int pt_y = default, uint time = default) + { + this.hwnd = hwnd; + this.message = msg; + this.wParam = wParam; + this.lParam = lParam; + this.time = time; + this.pt_x = pt_x; + this.pt_y = pt_y; + } } } \ No newline at end of file