aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/General/gen_hotkeys/accelBlock.cpp
blob: e98245d7509925e3165aa2ad3d034bab2dd30412 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "gen_hotkeys.h"
#include "api__gen_hotkeys.h"
#include "./accelBlock.h"

static BOOL RegisterMessageProcessor(ifc_messageprocessor *processor, BOOL bRegister)
{
	if (NULL == WASABI_API_APP)
		return FALSE;
	
	if (bRegister)
		WASABI_API_APP->app_addMessageProcessor(processor);
	else 
		WASABI_API_APP->app_removeMessageProcessor(processor);
		
	return TRUE;
}

AcceleratorBlocker::AcceleratorBlocker(HWND hwndToBlock) : hwnd(hwndToBlock)
{
	RegisterMessageProcessor(this, TRUE);
}
AcceleratorBlocker::~AcceleratorBlocker()
{
	RegisterMessageProcessor(this, FALSE);
}

bool AcceleratorBlocker::ProcessMessage(MSG *pMsg)
{
	if (pMsg->hwnd != hwnd)
		return false;

	switch(pMsg->message)
	{
		case WM_KEYDOWN:
		case WM_SYSKEYDOWN:
			TranslateMessage(pMsg);
			DispatchMessageW(pMsg);
			return true;
	}
	return false;
}


#define CBCLASS AcceleratorBlocker
START_DISPATCH;
CB(IFC_MESSAGEPROCESSOR_PROCESS_MESSAGE, ProcessMessage)
END_DISPATCH;