[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("User32.dll"), CLSCompliant(false)]
[return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, int flags);
+ internal static extern bool PeekMessage(ref MSG msg, IntPtr hWnd, int messageFilterMin, int messageFilterMax, PeekMessageFlags flags);
#endregion
#endregion
+ #region PeekMessageFlags
+
+ [Flags]
+ enum PeekMessageFlags : uint
+ {
+ NoRemove = 0,
+ Remove = 1,
+ NoYield = 2
+ }
+
+ #endregion
+
#region ShowWindowCommand
/// <summary>
#endregion
- #region IsIdle
-
- bool IsIdle
- {
- get
- {
- MSG message = new MSG();
- return !Functions.PeekMessage(ref message, window.Handle, 0, 0, 0);
- }
- }
-
- #endregion
-
#region CreateWindow
IntPtr CreateWindow(int x, int y, int width, int height, string title, GameWindowFlags options, DisplayDevice device, IntPtr parentHandle)
#region public void ProcessEvents()
- private int ret;
MSG msg;
public void ProcessEvents()
{
- while (!IsIdle)
+ while (Functions.PeekMessage(ref msg, window.Handle, 0, 0, PeekMessageFlags.Remove))
{
- ret = Functions.GetMessage(ref msg, window.Handle, 0, 0);
- if (ret == -1)
- {
- throw new PlatformException(String.Format(
- "An error happened while processing the message queue. Windows error: {0}",
- Marshal.GetLastWin32Error()));
- }
-
Functions.TranslateMessage(ref msg);
Functions.DispatchMessage(ref msg);
}