static void DispatchPending(MSG *lpMsg) { // Process any messages in the queue. while (PeekMessageW(lpMsg, hWnd: HWND.NULL, wMsgFilterMin: WM_NULL, wMsgFilterMax: WM_NULL, PM_REMOVE) != FALSE) { _ = TranslateMessage(lpMsg); _ = DispatchMessageW(lpMsg); } }
private IntPtr MyGetMessageCb(int code, IntPtr wParam, IntPtr lParam) { unsafe { MSG *msg = (MSG *)lParam; if (msg->message == 0x02E0) { msg->message = 0; } } return(CallNextHookEx(IntPtr.Zero, code, wParam, lParam)); }
private unsafe int KBHookProc(int nCode, Int32 wParam, IntPtr lParam) { // 侦听键盘事件 if (nCode >= 0) { KBDLLHOOKSTRUCT *p = (KBDLLHOOKSTRUCT *)lParam; MSG msg; msg.message = (uint)wParam; msg.lParam = lParam; MSG *pmsg = &msg; base.Broadcast((IntPtr)pmsg); //KBDLLHOOKSTRUCT* p = (KBDLLHOOKSTRUCT*)lParam; //var k = (*p).vkCode; //switch ((WM)wParam) //{ // case WM.WM_KEYDOWN: // case WM.WM_SYSKEYDOWN: // { // //KeyEventArgs e = new KeyEventArgs(k); // //KeyDownEvent?.Invoke(this, e); // OnKeyDown((int)k); // } // break; // case WM.WM_KEYUP: // case WM.WM_SYSKEYUP: // { // //KeyEventArgs e = new KeyEventArgs(k); // //KeyUpEvent?.Invoke(this, e); // OnKeyUp((int)k); // } // break; // default: // break; //} } //如果返回1,则结束消息,这个消息到此为止,不再传递。 //如果返回0或调用CallNextHookEx函数则消息出了这个钩子继续往下传递,也就是传给消息真正的接受者 return(0);// return User32.CallNextHookEx(hHookProc, nCode, wParam, lParam); }
public static extern unsafe bool TranslateMessage(MSG *msg);
public HRESULT OnTranslateMessage([NativeTypeName("const MSG *")] MSG *pMsg) { return(((delegate * unmanaged <IActiveIMMMessagePumpOwner *, MSG *, int>)(lpVtbl[5]))((IActiveIMMMessagePumpOwner *)Unsafe.AsPointer(ref this), pMsg)); }
public int TranslateAccelerator([NativeTypeName("MSG *")] MSG *pMsg) { return(((delegate * stdcall <IPropertyPageSite *, MSG *, int>)(lpVtbl[6]))((IPropertyPageSite *)Unsafe.AsPointer(ref this), pMsg)); }
public int TranslateAccelerator([NativeTypeName("LPMSG")] MSG *lpmsg, [NativeTypeName("WORD")] ushort wID) { return(((delegate * unmanaged <IOleInPlaceFrame *, MSG *, ushort, int>)(lpVtbl[14]))((IOleInPlaceFrame *)Unsafe.AsPointer(ref this), lpmsg, wID)); }
public int TranslateAccelerator(MSG *pMsg, [NativeTypeName("DWORD")] uint grfModifiers) { return(((delegate * unmanaged <IOleControlSite *, MSG *, uint, int>)(lpVtbl[7]))((IOleControlSite *)Unsafe.AsPointer(ref this), pMsg, grfModifiers)); }
public HRESULT ProcessInput([NativeTypeName("const MSG *")] MSG *message, BOOL *handled) { return(((delegate * unmanaged <IDirectManipulationManager3 *, MSG *, BOOL *, int>)(lpVtbl[6]))((IDirectManipulationManager3 *)Unsafe.AsPointer(ref this), message, handled)); }
public static extern unsafe IntPtr DispatchMessageW([Out] MSG *msg);
private static extern BOOL GetMessageA(MSG *lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax);
public int GetMessageW([NativeTypeName("LPMSG")] MSG *pMsg, [NativeTypeName("HWND")] IntPtr hwnd, [NativeTypeName("UINT")] uint wMsgFilterMin, [NativeTypeName("UINT")] uint wMsgFilterMax, [NativeTypeName("BOOL *")] int *pfResult) { return(((delegate * unmanaged <ITfMessagePump *, MSG *, IntPtr, uint, uint, int *, int>)(lpVtbl[6]))((ITfMessagePump *)Unsafe.AsPointer(ref this), pMsg, hwnd, wMsgFilterMin, wMsgFilterMax, pfResult)); }
public int DoVerb([NativeTypeName("LONG")] int iVerb, [NativeTypeName("LPMSG")] MSG *lpmsg, [NativeTypeName("IOleClientSite *")] IOleClientSite *pActiveSite, [NativeTypeName("LONG")] int lindex, [NativeTypeName("HWND")] IntPtr hwndParent, [NativeTypeName("LPCRECT")] RECT *lprcPosRect) { return(((delegate * unmanaged <IOleObject *, int, MSG *, IOleClientSite *, int, IntPtr, RECT *, int>)(lpVtbl[11]))((IOleObject *)Unsafe.AsPointer(ref this), iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect)); }
public static extern bool PeekMessage(MSG *lpMsg, IntPtr hwnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
public static extern void *DispatchMessage(MSG *lpMsg);
public static extern bool TranslateMessage(MSG *lpMsg);
public static extern int GetMessage(MSG *lpMsg, IntPtr hwnd, uint wMsgFilterMin, uint wMsgFilterMax);
public static extern unsafe bool GetMessageW([Out] MSG *msg, IntPtr hwnd, uint wMsgFilterMin, uint wMsgFilterMax);
public static extern unsafe bool PeekMessageW([Out] MSG *msg, IntPtr hwnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
private static extern BOOL PeekMessageA(MSG *lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg);
public int OnMnemonic([NativeTypeName("MSG *")] MSG *pMsg) { return(((delegate * unmanaged <IOleControl *, MSG *, int>)(lpVtbl[4]))((IOleControl *)Unsafe.AsPointer(ref this), pMsg)); }
private static extern BOOL TranslateMessage(MSG *lpMsg);
public HRESULT OnTranslateAccelerator(MSG *pMsg, [NativeTypeName("DWORD")] uint grfModifiers) { return(((delegate * unmanaged <IExpDispSupport *, MSG *, uint, int>)(lpVtbl[4]))((IExpDispSupport *)Unsafe.AsPointer(ref this), pMsg, grfModifiers)); }
private static extern LRESULT DispatchMessageA(MSG *lpMsg);
public HRESULT TranslateAccelerator([NativeTypeName("LPMSG")] MSG *lpmsg) { return(((delegate * unmanaged <IOleInPlaceActiveObject *, MSG *, int>)(lpVtbl[5]))((IOleInPlaceActiveObject *)Unsafe.AsPointer(ref this), lpmsg)); }
public int PreTranslateMessage([NativeTypeName("const MSG *")] MSG *message, [NativeTypeName("BOOL *")] int *result) { return(((delegate * unmanaged <IDesktopWindowXamlSourceNative2 *, MSG *, int *, int>)(lpVtbl[5]))((IDesktopWindowXamlSourceNative2 *)Unsafe.AsPointer(ref this), message, result)); }
public HRESULT TranslateAccelerator(MSG *pMsg) { return(((delegate * unmanaged <IPropertyPage *, MSG *, int>)(lpVtbl[13]))((IPropertyPage *)Unsafe.AsPointer(ref this), pMsg)); }
public HRESULT TranslateAcceleratorW(MSG *pmsg) { return(((delegate * unmanaged <IPreviewHandlerFrame *, MSG *, int>)(lpVtbl[4]))((IPreviewHandlerFrame *)Unsafe.AsPointer(ref this), pmsg)); }
public HRESULT TranslateAcceleratorW(MSG *pmsg) { return(((delegate * unmanaged <IShellView *, MSG *, int>)(lpVtbl[5]))((IShellView *)Unsafe.AsPointer(ref this), pmsg)); }
private unsafe int MouseHookProc(int nCode, Int32 wParam, IntPtr lParam) { //const int XBUTTON1 = 0x10000; //65536; //const int XBUTTON2 = 0x20000; //131072; // 侦听键盘事件 if (nCode >= 0) { MSG msg; msg.message = (uint)wParam; msg.lParam = lParam; MSG *pmsg = &msg; base.Broadcast((IntPtr)pmsg); //MSLLHOOKSTRUCT* p = (MSLLHOOKSTRUCT*)lParam; //Keys k = 0; //switch ((WM)wParam) //{ // case WM.WM_LBUTTONDOWN: k = Keys.LButton; goto RAISE_EVENT_KEYDOWN; // case WM.WM_RBUTTONDOWN: k = Keys.RButton; goto RAISE_EVENT_KEYDOWN; // case WM.WM_MBUTTONDOWN: k = Keys.MButton; goto RAISE_EVENT_KEYDOWN; // case WM.WM_XBUTTONDOWN: // switch (p->mouseData) // { // case XBUTTON1: k = Keys.XButton1;break; // case XBUTTON2: k = Keys.XButton2; break; // default: // break; // } // goto RAISE_EVENT_KEYDOWN; // //case WM.WM_XBUTTONDOWN:k = Keys.XButton2;goto RAISE_EVENT_KEYDOWN; // RAISE_EVENT_KEYDOWN: // { // //KeyEventArgs e = new KeyEventArgs(k); // //KeyDown?.Invoke(this, e); // OnKeyDown((int)k); // } // break; // case WM.WM_LBUTTONUP: k = Keys.LButton; goto RAISE_EVENT_KEYUP; // case WM.WM_RBUTTONUP: k = Keys.RButton; goto RAISE_EVENT_KEYUP; // case WM.WM_MBUTTONUP: k = Keys.MButton; goto RAISE_EVENT_KEYUP; // case WM.WM_XBUTTONUP: // switch (p->mouseData) // { // case XBUTTON1: k = Keys.XButton1; break; // case XBUTTON2: k = Keys.XButton2; break; // default: // break; // } // goto RAISE_EVENT_KEYUP; // //case WM.WM_XBUTTONUP:k = Keys.XButton2;goto RAISE_EVENT_KEYUP; // RAISE_EVENT_KEYUP: // { // //KeyEventArgs e = new KeyEventArgs(k); // //KeyUpEvent?.Invoke(this, e); // OnKeyUp((int)k); // } // break; // case WM.WM_MOUSEMOVE: // return 0; // break; // default: // break; //} } //如果返回1,则结束消息,这个消息到此为止,不再传递。 //如果返回0或调用CallNextHookEx函数则消息出了这个钩子继续往下传递,也就是传给消息真正的接受者 return(0);// return User32.CallNextHookEx(hHookProc, nCode, wParam, lParam); }