1
0

accelBlock.cpp 953 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "gen_hotkeys.h"
  2. #include "api__gen_hotkeys.h"
  3. #include "./accelBlock.h"
  4. static BOOL RegisterMessageProcessor(ifc_messageprocessor *processor, BOOL bRegister)
  5. {
  6. if (NULL == WASABI_API_APP)
  7. return FALSE;
  8. if (bRegister)
  9. WASABI_API_APP->app_addMessageProcessor(processor);
  10. else
  11. WASABI_API_APP->app_removeMessageProcessor(processor);
  12. return TRUE;
  13. }
  14. AcceleratorBlocker::AcceleratorBlocker(HWND hwndToBlock) : hwnd(hwndToBlock)
  15. {
  16. RegisterMessageProcessor(this, TRUE);
  17. }
  18. AcceleratorBlocker::~AcceleratorBlocker()
  19. {
  20. RegisterMessageProcessor(this, FALSE);
  21. }
  22. bool AcceleratorBlocker::ProcessMessage(MSG *pMsg)
  23. {
  24. if (pMsg->hwnd != hwnd)
  25. return false;
  26. switch(pMsg->message)
  27. {
  28. case WM_KEYDOWN:
  29. case WM_SYSKEYDOWN:
  30. TranslateMessage(pMsg);
  31. DispatchMessageW(pMsg);
  32. return true;
  33. }
  34. return false;
  35. }
  36. #define CBCLASS AcceleratorBlocker
  37. START_DISPATCH;
  38. CB(IFC_MESSAGEPROCESSOR_PROCESS_MESSAGE, ProcessMessage)
  39. END_DISPATCH;