Click here to Skip to main content
15,908,455 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionWhat's wrong with my hook? Pin
Old Gun30-May-03 14:43
Old Gun30-May-03 14:43 
1.What 's wrong with my MouseProc hook?

LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam)
{
LPMOUSEHOOKSTRUCT pMouseHook=(MOUSEHOOKSTRUCT FAR *)lParam;
if (nCode>=0)
{
HWND glhTargetWnd=pMouseHook->hwnd;
HWND ParentWnd=glhTargetWnd;
while (ParentWnd !=NULL)
{
glhTargetWnd=ParentWnd;
ParentWnd=GetParent(glhTargetWnd);
}
if(glhTargetWnd!=glhPrevTarWnd)
{
char szClassName[40];
GetClassName(glhTargetWnd,szClassName,20);
if (stricmp(szClassName,"XLMAIN")==0)//Excel Main Window
{
switch(wParam)
{
case WM_RBUTTONUP:
case WM_RBUTTONDOWN:

//....
//Here I want stop the message to XLMAIN Window
//
strcat(szClassName,"You press right mouse button");
//Infact my program never go here when I click each mouse button,Why?
TRACE0(szClassName);
break;
case WM_LBUTTONUP:
case WM_LBUTTONDOWN:
strcat(szClassName,"You press left mouse butto");
//Infact my program never go here when I click each mouse button,Why
TRACE0(szClassName);
default:
AfxMessageBox("Mouse is in Excel Window");//program goes here
}
glhPrevTarWnd=glhTargetWnd;
}
SendMessage(glhDisplayWnd,WM_SETTEXT,0,(LPARAM)(LPCTSTR)szClassName);
//glhDisplayWnd-CEdit window HWND,This is just for test.
}
}
return CallNextHookEx(glhHook,nCode,wParam,lParam);
}


2.how to cancel special message to a special window
AnswerRe: How to deal windows message in MouseProc Hook? Pin
Neville Franks31-May-03 2:04
Neville Franks31-May-03 2:04 
GeneralRe: How to deal windows message in MouseProc Hook? Pin
Neville Franks31-May-03 21:53
Neville Franks31-May-03 21:53 
Generaldialog created with DialogBox not receiving all messages Pin
Kibble30-May-03 13:15
Kibble30-May-03 13:15 
GeneralRe: dialog created with DialogBox not receiving all messages Pin
Neville Franks31-May-03 2:06
Neville Franks31-May-03 2:06 
GeneralRe: dialog created with DialogBox not receiving all messages Pin
Kibble31-May-03 11:26
Kibble31-May-03 11:26 
GeneralCEdit updates in dialog box Pin
rpadrela30-May-03 11:49
rpadrela30-May-03 11:49 
GeneralRe: CEdit updates in dialog box Pin
valikac30-May-03 13:24
valikac30-May-03 13:24 
GeneralRe: CEdit updates in dialog box Pin
Peter Weyzen30-May-03 21:49
Peter Weyzen30-May-03 21:49 
GeneralKeep the cursor inside a window Pin
Daniela12330-May-03 11:36
Daniela12330-May-03 11:36 
GeneralRe: Keep the cursor inside a window Pin
Michael Dunn30-May-03 11:50
sitebuilderMichael Dunn30-May-03 11:50 
GeneralRe: Keep the cursor inside a window Pin
Anonymous31-May-03 17:18
Anonymous31-May-03 17:18 
Generalraw packet with setsockopt() and sendto() Pin
Kuniva30-May-03 11:32
Kuniva30-May-03 11:32 
GeneralRe: raw packet with setsockopt() and sendto() Pin
JohnnyG30-May-03 18:34
JohnnyG30-May-03 18:34 
GeneralRe: raw packet with setsockopt() and sendto() Pin
Kuniva31-May-03 5:11
Kuniva31-May-03 5:11 
GeneralRe: raw packet with setsockopt() and sendto() Pin
JohnnyG31-May-03 13:20
JohnnyG31-May-03 13:20 
GeneralRe: raw packet with setsockopt() and sendto() Pin
Peter Weyzen30-May-03 22:01
Peter Weyzen30-May-03 22:01 
GeneralMySQL in a small app... Pin
Gnascher30-May-03 10:25
Gnascher30-May-03 10:25 
GeneralRe: MySQL in a small app... Pin
Robert Little30-May-03 11:12
Robert Little30-May-03 11:12 
GeneralRe: MySQL in a small app... Pin
Anonymous30-May-03 12:00
Anonymous30-May-03 12:00 
GeneralRe: MySQL in a small app... Pin
Robert Little30-May-03 18:21
Robert Little30-May-03 18:21 
GeneralRe: MySQL in a small app... Pin
Neville Franks30-May-03 13:29
Neville Franks30-May-03 13:29 
GeneralRe: MySQL in a small app... Pin
Gnascher30-May-03 14:20
Gnascher30-May-03 14:20 
GeneralRe: MySQL in a small app... Pin
Neville Franks31-May-03 0:21
Neville Franks31-May-03 0:21 
QuestionHow to get control(button) ID in runtime Pin
Roman Muntyanu30-May-03 10:22
Roman Muntyanu30-May-03 10:22 

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.