让VB开发环境支持鼠标滚轮(3)
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);
- 上一篇:VB 列出系统所有字体
- 下一篇:用VB编写Hanoi塔问题动态演示程序[组图]