using System;
using System.Reflection;
using System.Windows.Forms;

namespace Qualcomm.GUI;

public class WindowsMessaging
{
	public class Messages
	{
		public const int WM_MOUSEMOVE = 512;

		public const int WM_LBUTTONDOWN = 513;

		public const int WM_LBUTTONUP = 514;

		public const int WM_RBUTTONDOWN = 516;

		public const int WM_LBUTTONDBLCLK = 515;

		public const int WM_MOUSELEAVE = 675;

		public const int WM_PAINT = 15;

		public const int WM_ERASEBKGND = 20;

		public const int WM_PRINT = 791;

		public const int WM_HSCROLL = 276;

		public const int WM_VSCROLL = 277;

		public const int WM_SCROLL = 181;

		public const int WM_PRINTCLIENT = 792;

		public const int WM_CLOSE = 16;
	}

	public class Params
	{
		public const long PRF_CHECKVISIBLE = 1L;

		public const long PRF_NONCLIENT = 2L;

		public const long PRF_CLIENT = 4L;

		public const long PRF_ERASEBKGND = 8L;

		public const long PRF_CHILDREN = 16L;

		public const long PRF_OWNED = 32L;

		public const int SB_TOP = 6;

		public const int SB_BOTTOM = 7;
	}

	public static void ScrollToBottom(Control scrollControl)
	{
		PostMessageToControl(scrollControl, 181, (IntPtr)7, (IntPtr)0);
	}

	public static void ScrollToTop(Control scrollControl)
	{
		PostMessageToControl(scrollControl, 181, (IntPtr)6, (IntPtr)0);
	}

	public static void PostMessageToControl(Control Ctrl, int WinMessage, IntPtr wParam, IntPtr lParam)
	{
		Message message = Message.Create(Ctrl.Handle, WinMessage, wParam, lParam);
		Ctrl.GetType().InvokeMember("WndProc", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, Ctrl, new object[1] { message });
	}

	public static void PostMessageToControl(Form form, int WinMessage, IntPtr wParam, IntPtr lParam)
	{
		Message message = Message.Create(form.Handle, WinMessage, wParam, lParam);
		form.GetType().InvokeMember("WndProc", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, form, new object[1] { message });
	}
}
