龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VB开发 >

让VB开发环境支持鼠标滚轮(3)

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
case WH_GETMESSAGE: bResult=UnhookWindowsHookEx(g_hMsgProc); g_hMsgProc=NULL; break; default: bResult=TRUE; } return bResult; } 下面的函数就是对PostMessage发送的消息的响应函数,其中

         case WH_GETMESSAGE:

                  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);

精彩图集

赞助商链接