Added MSG <-> Message conversion functions

pull/30/head
David Hall 2019-01-08 08:17:19 -07:00
parent 77d9cb57a4
commit f2605821b6
1 changed files with 11 additions and 1 deletions

View File

@ -182,5 +182,15 @@ namespace Vanara.Extensions
SetWindowLong(href, WindowLongFlags.GWL_STYLE, new IntPtr(oldstyle & ~style));
ctrl.Refresh();
}
/// <summary>Converts a <see cref="PInvoke.MSG"/> structure to a <see cref="Message"/> structure.</summary>
/// <param name="msg">The MSG instance.</param>
/// <returns>An equivalent <see cref="Message"/> structure.</returns>
public static Message ToMessage(this PInvoke.MSG msg) => Message.Create((IntPtr)msg.hwnd, (int)msg.message, msg.wParam, msg.lParam);
/// <summary>Converts a <see cref="Message"/> structure to a <see cref="PInvoke.MSG"/> structure.</summary>
/// <param name="msg">The Message instance.</param>
/// <returns>An equivalent <see cref="PInvoke.MSG"/> structure.</returns>
public static PInvoke.MSG ToMSG(this Message msg) => new PInvoke.MSG { message = (uint)msg.Msg, hwnd = msg.HWnd, wParam = msg.WParam, lParam = msg.LParam };
}
}
}