using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using System.Runtime.InteropServices;
|
|
namespace HotelPms.Share.Windows.Component
|
{
|
/// <summary>
|
/// Û¯³êÄ¢éEBhEbZ[Wðí
|
/// </summary>
|
public static class RemovePeekMessage
|
{
|
#region è
|
/// <summary>
|
/// Y·éEBhEÉÄ`æªKvÆOSª»fµ½Æ«É|Xg³êébZ[W
|
/// </summary>
|
private const int WM_PAINT = 0xF;
|
|
/// <summary>
|
/// EBhEÌNCAgÌæÅ[U[ª}EXÌÚ®ðµ½Æ«É|Xg³êébZ[W
|
/// </summary>
|
private const int WM_MOUSEMOVE = 0x200;
|
|
/// <summary>
|
/// EBhEÌNCAgÌæÅ[U[ª}EX̶{^ðµ½Æ«É|Xg³êébZ[W
|
/// </summary>
|
private const int WM_LBUTTONDOWN = 0x201;
|
|
/// <summary>
|
/// EBhEÌNCAgÌæÅ[U[ª}EX̶{^𣵽ƫÉ|Xg³êébZ[W
|
/// </summary>
|
private const int WM_LBUTTONUP = 0x202;
|
|
/// <summary>
|
/// }EX|C^ªÌæOÉo½É|Xg³êébZ[W
|
/// </summary>
|
private const int WM_MOUSELEAVE = 0x2A3;
|
|
private const int WM_KEYFIRST = 0x100;
|
private const int WM_KEYLAST = 0x109;
|
|
private const int WM_MOUSEFIRST = 0x200;
|
private const int WM_MOUSELAST = 0x20D;
|
|
#endregion
|
|
#region \¢Ì
|
/// <summary>
|
/// MSG \¢Ì^
|
/// </summary>
|
[StructLayout(LayoutKind.Sequential)]
|
public struct MSG
|
{
|
/// <summary>
|
/// EBhEnh
|
/// </summary>
|
public IntPtr hWnd;
|
/// <summary>
|
/// MessageID
|
/// </summary>
|
public int msg;
|
/// <summary>
|
/// WParamtB[hiMessageID²ÆÉá¤æ)
|
/// </summary>
|
public IntPtr wParam;
|
/// <summary>
|
/// LParamtB[hiMessageID²ÆÉá¤æ)
|
/// </summary>
|
public IntPtr lParam;
|
/// <summary>
|
/// Ô
|
/// </summary>
|
public int time;
|
/// <summary>
|
/// J[\ÊuiXN[ÀWj
|
/// </summary>
|
public POINTAPI pt;
|
}
|
|
/// <summary>
|
/// POINTAPI\¢Ì
|
/// </summary>
|
[StructLayout(LayoutKind.Sequential)]
|
public struct POINTAPI
|
{
|
/// <summary>
|
/// XÀW
|
/// </summary>
|
public int x;
|
/// <summary>
|
/// YÀW
|
/// </summary>
|
public int y;
|
}
|
#endregion
|
|
#region ñ^
|
/// <summary>
|
/// wRemoveMsgÅpÂ\ÈIvV
|
/// </summary>
|
enum EPeekMessageOption
|
{
|
/// <summary>
|
/// ãbZ[WðL
[©çíµÈ¢
|
/// </summary>
|
PM_NOREMOVE = 0,
|
/// <summary>
|
/// ãbZ[WðL
[©çí·é
|
/// </summary>
|
PM_REMOVE
|
}
|
#endregion
|
|
#region DllImport
|
/// <summary>
|
/// XbhÌbZ[WL
[ÉbZ[Wª é©Ç¤©ð`FbNµ
|
/// êÎAwè³ê½\¢ÌÉ»ÌbZ[Wði[µÜ·
|
/// </summary>
|
/// <param name="lpMsg"> bZ[Wîñði[·éAMSG \¢Ì^ÏÌ|C^ðwèµÜ·</param>
|
/// <param name="hWnd">bZ[Wðæ¾·éEBhEÌnhðwèµÜ·BSÄÌêÍ NULL</param>
|
/// <param name="wMsgFilterMin">bZ[WÌŬlðwèµAtB^OµÜ·BµÈ¢êÍ0</param>
|
/// <param name="wMsgFilterMax">bZ[WÌÅålðwèµAtB^OµÜ·BµÈ¢êÍ0</param>
|
/// <param name="wRemoveMsg">ãbZ[WðL
[ðí·é©Û©</param>
|
/// <returns>bZ[Wðæ¾µ½Æ«Í 0 ÈOA澵ȩÁ½Æ«Í 0</returns>
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
private static extern bool PeekMessage(
|
out MSG lpMsg,
|
int hWnd,
|
int wMsgFilterMin,
|
int wMsgFilterMax,
|
EPeekMessageOption wRemoveMsg
|
);
|
|
/// <summary>
|
/// wè³ê½ MSG \¢Ì^ÏÉbZ[Wði[µÜ·
|
/// </summary>
|
/// <param name="lpMsg">bZ[Wîñði[·éAMSG \¢Ì^ÏÌ|C^ðwèµÜ·</param>
|
/// <param name="hWnd">bZ[Wðæ¾·éEBhEÌnhðwèµÜ·BSÄÌêÍ NULL</param>
|
/// <param name="wMsgFilterMin">bZ[WÌŬlðwèµAtB^OµÜ·BµÈ¢êÍ0</param>
|
/// <param name="wMsgFilterMax">bZ[WÌÅålðwèµAtB^OµÜ·BµÈ¢êÍ0</param>
|
/// <returns></returns>
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
private static extern bool GetMessage(
|
out MSG lpMsg,
|
int hWnd,
|
int wMsgFilterMin,
|
int wMsgFilterMax
|
);
|
|
/// <summary>
|
/// wè³ê½EBhEbZ[WðEBhEvV[WÉfBXpb`µÜ·
|
/// </summary>
|
/// <param name="lpMsg">fBXpb`·ébZ[Wði[µ½ MSG \¢ÌÏÌ|C^ðwèµÜ·</param>
|
/// <returns>EBhEvV[WÌßèl</returns>
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
private static extern IntPtr DispatchMessage(
|
out MSG lpMsg
|
);
|
#endregion
|
|
#region \bh
|
/// <summary>
|
/// Û¯³êÄ¢éEBhEbZ[WðíµÜ·B
|
/// </summary>
|
public static void Invoke()
|
{
|
//Console.WriteLine("y¦zRemovePeekMessage.Invoke():±Ì_ÌCxg·×ÄíÀsJn");
|
MSG wm;
|
while (PeekMessage(out wm, 0, WM_KEYFIRST, WM_KEYLAST, EPeekMessageOption.PM_REMOVE)) { }
|
while (PeekMessage(out wm, 0, WM_MOUSEFIRST, WM_MOUSELAST, EPeekMessageOption.PM_REMOVE)) { }
|
|
|
#if false
|
System.Diagnostics.Debug.WriteLine("Invoke begin");
|
MSG wm;
|
while (true)
|
{
|
bool ret = PeekMessage(out wm, 0, 0, 0, EPeekMessageOption.PM_REMOVE);
|
System.Diagnostics.Debug.WriteLine(wm.msg.ToString());
|
System.Diagnostics.Debug.WriteLine(ret.ToString());
|
if (!ret) { break; }
|
|
switch (wm.msg)
|
{
|
case WM_LBUTTONUP:
|
case WM_MOUSELEAVE:
|
case WM_PAINT:
|
System.Diagnostics.Debug.WriteLine(wm.msg.ToString());
|
DispatchMessage(out wm);
|
break;
|
}
|
}
|
System.Diagnostics.Debug.WriteLine("Invoke end");
|
#endif
|
}
|
#endregion
|
}
|
}
|