bResult=UnhookWindowsHookEx(g_hMsgProc);
g_hMsgProc=NULL;
break;
default:
bResult=TRUE;
}
return bResult;
}
下面的函数就是对PostMessage发送的消息的响应函数,其中对鼠标滚轮事件进行了响应,使VB支持滚轮。
LRESULT __declspec(dllexport)__stdcall CALLBACK ProcessMsgProc(
int nCode, // hook code
WPARAM wParam, // current-process flag
LPARAM lParam // address of structure with message data
)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
int n=0;
MSG *pMessage=(MSG*)lParam;
CWnd *pWnd=NULL;
CWnd *pScroll=NULL;
char buf[256];
if(pMessage->message==WM_MOUSEWHEEL && g_bVBHelper)
{
pWnd=CWnd::FromHandle(pMessage->hwnd);
if(pWnd!=NULL)
{
::GetClassName(pMessage->hwnd,buf,255);
CString sWndClass(buf);
if(sWndClass.Compare("VbaWindow")==0)
{
pScroll=pWnd->GetWindow(GW_CHILD);
while(pScroll!=NULL)
{
::GetClassName(pScroll->GetSafeHwnd(),buf,255);
sWndClass.Format("%s",buf);
if(sWndClass.Compare("ScrollBar")==0 && (pScroll->GetStyle()& SBS_VERT))
{
break;
}
pScroll=pScroll->GetWindow(GW_HWNDNEXT);
}
if(((short) HIWORD(pMessage->wParam)<0))
&nbs 上一页 [1] [2] [3] 下一页 没有相关教程
|