打印本文 打印本文 关闭窗口 关闭窗口
让VB开发环境支持鼠标滚轮
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2778  更新时间:2009/4/23 18:59:51  文章录入:mintao  责任编辑:mintao
                  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]  下一页

打印本文 打印本文 关闭窗口 关闭窗口