Click here to Skip to main content
15,903,362 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: size of a compiled exe Pin
David Crow25-May-04 2:24
David Crow25-May-04 2:24 
GeneralHooks and Message Blocking Pin
User 1278224-May-04 15:09
User 1278224-May-04 15:09 
GeneralRe: Hooks and Message Blocking Pin
Ryan Binns24-May-04 18:22
Ryan Binns24-May-04 18:22 
GeneralRe: Hooks and Message Blocking Pin
User 1278224-May-04 18:47
User 1278224-May-04 18:47 
GeneralRe: Hooks and Message Blocking Pin
Blake Miller25-May-04 14:53
Blake Miller25-May-04 14:53 
GeneralRe: Hooks and Message Blocking Pin
User 1278225-May-04 15:24
User 1278225-May-04 15:24 
GeneralRe: Hooks and Message Blocking Pin
Blake Miller25-May-04 15:31
Blake Miller25-May-04 15:31 
GeneralRe: Hooks and Message Blocking Pin
User 1278225-May-04 15:42
User 1278225-May-04 15:42 
I'm using separate functions for the hook. They are below:

LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	if(HC_ACTION==nCode)
	{
		switch(wParam)
		{
		case WM_MOUSEMOVE:
		case WM_NCMOUSEMOVE:
			PostMessage(g_hWnd,g_hMouseMove,wParam,lParam);
			break;

		default:
			PostMessage(g_hWnd,g_hMouseAct,wParam,lParam);
				break;
		}
	}

	if(g_bBlock)
		return -1;

	return CallNextHookEx(g_hHookMouse,nCode,wParam,lParam);
}

LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	if(HC_ACTION==nCode)
	{
		PostMessage(g_hWnd,g_hKeyboard,wParam,lParam);
	}

	if(g_bBlock)
		return -1;
	return CallNextHookEx(g_hHookKey,nCode,wParam,lParam);
}


I install the hooks with this:

g_hHookMouse=SetWindowsHookEx(WH_MOUSE,MouseProc,g_hInst,0);
if(NULL==g_hHookMouse)
    return FALSE;

g_hHookKey=SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,g_hInst,0);
if(NULL==g_hHookKey)
    return FALSE;


If g_bBlock is true, then it will block the mouse messages and the keyboard messages, though my app will still be able to process the mouse messages, but not the keyboard messages.

Maybe I misunderstood you, please tell me if I did.

modified 12-Jul-20 21:01pm.

GeneralRe: Hooks and Message Blocking Pin
Blake Miller25-May-04 16:01
Blake Miller25-May-04 16:01 
GeneralRe: Hooks and Message Blocking Pin
User 1278225-May-04 16:36
User 1278225-May-04 16:36 
GeneralRe: Hooks and Message Blocking Pin
Blake Miller26-May-04 7:09
Blake Miller26-May-04 7:09 
GeneralRe: Hooks and Message Blocking Pin
User 1278226-May-04 10:30
User 1278226-May-04 10:30 
GeneralRe: Hooks and Message Blocking Pin
Blake Miller26-May-04 10:37
Blake Miller26-May-04 10:37 
GeneralRe: Hooks and Message Blocking Pin
User 1278226-May-04 10:40
User 1278226-May-04 10:40 
GeneralRe: Hooks and Message Blocking Pin
Anonymous14-Jul-04 10:03
Anonymous14-Jul-04 10:03 
GeneralRe: Hooks and Message Blocking Pin
Blake Miller14-Jul-04 10:41
Blake Miller14-Jul-04 10:41 
GeneralRe: Hooks and Message Blocking Pin
Blake Miller14-Jul-04 10:25
Blake Miller14-Jul-04 10:25 
GeneralMFC IO Pin
ANDYFA24-May-04 14:30
ANDYFA24-May-04 14:30 
GeneralRe: MFC IO Pin
valikac24-May-04 14:38
valikac24-May-04 14:38 
GeneralRe: MFC IO Pin
Antony M Kancidrowski25-May-04 1:18
Antony M Kancidrowski25-May-04 1:18 
GeneralImage scaling Pin
RalfPeter24-May-04 12:58
RalfPeter24-May-04 12:58 
GeneralRe: Image scaling Pin
Member 42102524-May-04 13:13
Member 42102524-May-04 13:13 
GeneralRe: Image scaling Pin
Christian Graus24-May-04 13:19
protectorChristian Graus24-May-04 13:19 
GeneralRe: Image scaling Pin
Johann Gerell24-May-04 23:49
Johann Gerell24-May-04 23:49 
GeneralRe: Image scaling Pin
Christian Graus25-May-04 11:53
protectorChristian Graus25-May-04 11:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.