internal static int GetMessage(ref UnsafeNativeMethods.MSG msg, NativeMethods.HWND hwnd, int nMsgFilterMin, int nMsgFilterMax) { int result = UnsafeNativeMethods.GetMessage(ref msg, hwnd, nMsgFilterMin, nMsgFilterMax); int lastWin32Error = Marshal.GetLastWin32Error(); if (result == -1) { ThrowWin32ExceptionsIfError(lastWin32Error); } return(result); }
//------------------------------------------------------ // // Private Methods // //------------------------------------------------------ #region Private Methods // The loop the thread uses to wait for queue items to process private void WaitForWork() { SafeWaitHandle handle = _ev.SafeWaitHandle; UnsafeNativeMethods.MSG msg = new UnsafeNativeMethods.MSG(); while (!_quitting) { // pump any messages while (UnsafeNativeMethods.PeekMessage(ref msg, NativeMethods.HWND.NULL, 0, 0, UnsafeNativeMethods.PM_REMOVE)) { if (msg.message == UnsafeNativeMethods.WM_QUIT) { break; } // From the Windows SDK documentation: // The return value specifies the value returned by the window procedure. // Although its meaning depends on the message being dispatched, the return // value generally is ignored. #pragma warning suppress 6031, 6523 UnsafeNativeMethods.DispatchMessage(ref msg); } // do any work items in the queue DrainQueue(); int lastWin32Error = 0; int result = Misc.TryMsgWaitForMultipleObjects(handle, false, UnsafeNativeMethods.INFINITE, UnsafeNativeMethods.QS_ALLINPUT, ref lastWin32Error); if (result == UnsafeNativeMethods.WAIT_FAILED || result == UnsafeNativeMethods.WAIT_TIMEOUT) { DrainQueue(); Debug.Assert(_quitting, "MsgWaitForMultipleObjects failed while WaitForWork"); break; } } DrainQueue(); }
int UnsafeNativeMethods.IDocHostUIHandler.TranslateAccelerator(ref UnsafeNativeMethods.MSG msg, ref Guid group, int nCmdID) { if (msg.message != WinApi.WM_KEYDOWN) { return(_baseIDocHostUIHandler.TranslateAccelerator(ref msg, ref @group, nCmdID)); } KeyEventArgs e = new KeyEventArgs((Keys)((int)msg.wParam & 0xff) | Control.ModifierKeys); if ((e.Modifiers == Keys.Control && (e.KeyCode == Keys.O || e.KeyCode == Keys.L || e.KeyCode == Keys.F || e.KeyCode == Keys.P || e.KeyCode == Keys.N || e.KeyCode == Keys.Oemplus || e.KeyCode == Keys.OemMinus)) || e.KeyCode == Keys.F5) { return(0); } else { return(_baseIDocHostUIHandler.TranslateAccelerator(ref msg, ref @group, nCmdID)); } }