abdul
Jul 26th, 2002, 06:06 PM
I have hooked my window and I am trying to know when a menu window is created as a new window is created. The class for the menu window is #32770 (I think) so I am using the following chunk of code to check when a menu window is created:
LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
CWPSTRUCT *cw;
string classname;
switch (nCode)
{
case HC_ACTION:
cw = (CWPSTRUCT*)lParam;
GetTheClassName(cw->hwnd, classname);
// MessageBox(cw->hwnd,classname.c_str(),"",MB_OK);
if(strcmp(classname.c_str(),"#32770") == 0)
{
MessageBox("A menu window was created","",MB_OK);
//A menu window was created
}
return CallNextHookEx(myhook,nCode,wParam,lParam);
}
return CallNextHookEx(myhook,nCode,wParam,lParam);
}
void GetTheClassName(HWND hWnd, string &classdest)
{
char classname[128];
GetClassName(hWnd,classname, 128);
classdest = classname;
}
Now if I uncomment the line MessageBox(cw
>hwnd,classname.c_str(),"",MB_OK); before I use the if statement, some of the class names ARE "#32770" so it should actually return 0 from strcmpy but it's NOT. It never shows the message box inside the if statement which says "A menu window was created".
LRESULT CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
CWPSTRUCT *cw;
string classname;
switch (nCode)
{
case HC_ACTION:
cw = (CWPSTRUCT*)lParam;
GetTheClassName(cw->hwnd, classname);
// MessageBox(cw->hwnd,classname.c_str(),"",MB_OK);
if(strcmp(classname.c_str(),"#32770") == 0)
{
MessageBox("A menu window was created","",MB_OK);
//A menu window was created
}
return CallNextHookEx(myhook,nCode,wParam,lParam);
}
return CallNextHookEx(myhook,nCode,wParam,lParam);
}
void GetTheClassName(HWND hWnd, string &classdest)
{
char classname[128];
GetClassName(hWnd,classname, 128);
classdest = classname;
}
Now if I uncomment the line MessageBox(cw
>hwnd,classname.c_str(),"",MB_OK); before I use the if statement, some of the class names ARE "#32770" so it should actually return 0 from strcmpy but it's NOT. It never shows the message box inside the if statement which says "A menu window was created".