rt
谢谢!
谢谢!
解决方案 »
- LISTBOX控件怎样删除选种的某一条记录,还有LISTCTRL控件,写详细代码,多谢
- 怎么获取阿里旺旺Internet Explorer_Server的消息啊
- 获取光驱状态
- 编写控件时对话框继承的问题,在线回答给分
- 一个很奇怪的问题
- 有没有那位大哥(大姐)会编写文件操作的相关函数
- 怎样测试串口的误码率?
- CMimeMessage::AttachFile类 64bit 发送附件中文为乱码!在线求解
- 2006年左右的老人们,可还有在这论坛的。
- 菜鸟问题,回答对马上给分。 如何设置edit的tab属性???
- 在VC6.0里用USING NAMESPACE STD为什么会出来STD找不到?
- 在树型控件中实现右键弹出菜单!!!
/****************************************************************************
* setMyHook
* Inputs:
* HWND hWnd: Window to notify
* Result: BOOL
* TRUE if successful
* FALSE if error
* Effect:
* Sets the hook
****************************************************************************/__declspec(dllexport) BOOL setMyHook(HWND hWnd)
{
if(hWndServer != NULL)
return FALSE; // already hooked!
hook = SetWindowsHookEx(WH_CBT,
(HOOKPROC)msghook,
hInst,
0);
::MessageBox(NULL,NULL,"SET",MB_OK);
if(hook != NULL)
{ /* success */
hWndServer = hWnd;
return TRUE;
} /* success */
return FALSE; // failed to set hook
} // setMyHook/****************************************************************************
* clearMyHook
* Inputs:
* HWND hWnd: Window hook
* Result: BOOL
* TRUE if successful
* FALSE if error
* Effect:
* Removes the hook that has been set
****************************************************************************/__declspec(dllexport) BOOL clearMyHook(HWND hWnd)
{
::MessageBox(NULL,NULL,"Clear",MB_OK);
if(hWnd != hWndServer || hWnd == NULL)
return FALSE;
BOOL unhooked = UnhookWindowsHookEx(hook);
if(unhooked)
hWndServer = NULL;
return unhooked;
} // clearMyHook/****************************************************************************
* msghook
* Inputs:
* int nCode: Code value
* WPARAM wParam:
* LPARAM lParam:
* Result: LRESULT
* Either 0 or the result of CallNextHookEx
* Effect:
* Hook processing function. If the message is a mouse-move message,
* posts the coordinates to the parent window
****************************************************************************/static LRESULT CALLBACK msghook(UINT nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode < 0)
{ /* pass it on */
CallNextHookEx(hook, nCode, wParam, lParam);
return 0;
} /* pass it on */
PCWPSTRUCT msg = (PCWPSTRUCT)lParam;
//::MessageBox(NULL,NULL,"MSG",MB_OK);
if(msg->message == HCBT_CREATEWND )
{
::MessageBox(NULL,NULL,"OK",MB_OK);
PostMessage(hWndServer, WM_CLOSE, 0, 0);
}
return CallNextHookEx(hook, nCode, wParam, lParam);
} // msghook
我的钩子怎么没起作用呀,在我的应用程序里面,我想拦截MessageBox的消息,对嘛?