12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System;
- using System.Runtime.InteropServices;
- using System.Windows.Forms;
- namespace LYFZ.OtherExpansion.Win32
- {
- public static class Win32Helper
- {
- public static bool LeftKeyPressed()
- {
- if (SystemInformation.MouseButtonsSwapped)
- {
- return NativeMethods.GetKeyState(2) < 0;
- }
- return NativeMethods.GetKeyState(1) < 0;
- }
- public static int HIWORD(int n)
- {
- return n >> 16 & 65535;
- }
- public static int HIWORD(IntPtr n)
- {
- return Win32Helper.HIWORD((int)((long)n));
- }
- public static int LOWORD(int n)
- {
- return n & 65535;
- }
- public static int LOWORD(IntPtr n)
- {
- return Win32Helper.LOWORD((int)((long)n));
- }
- public static int MAKELONG(int low, int high)
- {
- return high << 16 | (low & 65535);
- }
- public static IntPtr MAKELPARAM(int low, int high)
- {
- return (IntPtr)(high << 16 | (low & 65535));
- }
- public static int SignedHIWORD(int n)
- {
- return (int)((short)(n >> 16 & 65535));
- }
- public static int SignedHIWORD(IntPtr n)
- {
- return Win32Helper.SignedHIWORD((int)((long)n));
- }
- public static int SignedLOWORD(int n)
- {
- return (int)((short)(n & 65535));
- }
- public static int SignedLOWORD(IntPtr n)
- {
- return Win32Helper.SignedLOWORD((int)((long)n));
- }
- public static void Swap(ref int x, ref int y)
- {
- int tmp = x;
- x = y;
- y = tmp;
- }
- public static IntPtr ToIntPtr(object structure)
- {
- IntPtr lparam = IntPtr.Zero;
- lparam = Marshal.AllocCoTaskMem(Marshal.SizeOf(structure));
- Marshal.StructureToPtr(structure, lparam, false);
- return lparam;
- }
- public static void SetRedraw(IntPtr hWnd, bool redraw)
- {
- IntPtr ptr = redraw ? Result.TRUE : Result.FALSE;
- NativeMethods.SendMessage(hWnd, 11, ptr, 0);
- }
- }
- }
|