資源描述:
《實(shí)現(xiàn)按鍵c版的滾輪消息按鍵》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、//DLL#define_WIN32_WINNT0x0500#include_declspec(dllexport)BOOLMouseHK();//滾輪吃藥LRESULTCALLBACKHookProcMouse(intnCode,WPARAMwParam,LPARAMlParam);//鼠標(biāo)鉤子回調(diào)函數(shù)HHOOKhkMouse=NULL;//鼠標(biāo)鉤子句柄HINSTANCEhWnd=NULL;//DLL實(shí)例句柄BOOLMouseHK(){if(hkMouse){Unhook
2、WindowsHookEx(hkMouse);hkMouse=NULL;returnFALSE;}else{hkMouse=SetWindowsHookEx(WH_MOUSE,HookProcMouse,hWnd,0);returnTRUE;}}LRESULTCALLBACKHookProcMouse(intnCode,WPARAMwParam,LPARAMlParam){shortx;typedefstructtagMOUSEHOOKSTRUCTEX{MOUSEHOOKSTRUCTMOUSEH
3、OOKSTRUCT;DWORDmouseData;}MOUSEHOOKSTRUCTEX,*PMOUSEHOOKSTRUCTEX,*LPMOUSEHOOKSTRUCTEX;if(nCode>=0&&wParam==WM_MOUSEWHEEL){LPMOUSEHOOKSTRUCTEXm=(LPMOUSEHOOKSTRUCTEX)lParam;x=HIWORD(m->mouseData);if(x>0)keybd_event('2',0,0,0);elsekeybd_event('2',0,0,0);
4、}returnCallNextHookEx(hkMouse,nCode,wParam,lParam);}BOOLAPIENTRYDllMain(HANDLEhModule,DWORDul_reason_for_call,LPVOIDlpReserved){hWnd=(HINSTANCE)hModule;switch(ul_reason_for_call){caseDLL_PROCESS_ATTACH:break;caseDLL_THREAD_ATTACH:break;caseDLL_PROCES
5、S_DETACH:caseDLL_THREAD_DETACH:if(hkMouse)UnhookWindowsHookEx(hkMouse);break;}returnTRUE;}//APP#define_WIN32_WINNT0X0500#include#include#include"resource.h"#pragmacomment(lib,"hk.lib")_declspec(dllimport)BOOLMouseHK();BOOLWINAPIMa
6、inProc(HWNDhWnd,UINTuMsg,WPARAMwParam,LPARAMlParam);intAPIENTRYWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow){//TODO:Placecodehere.DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAIN),NULL,MainProc);return0;}BOOLWINAPIMainProc
7、(HWNDhWnd,UINTuMsg,WPARAMwParam,LPARAMlParam){switch(uMsg){caseWM_COMMAND:switch(LOWORD(wParam)){caseID_MOUSEHK:if(MouseHK())SetDlgItemText(hWnd,ID_MOUSEHK,_T("停止"));elseSetDlgItemText(hWnd,ID_MOUSEHK,_T("開始"));break;caseIDCANCEL:EndDialog(hWnd,NULL)
8、;}}returnFALSE;}//RC//MicrosoftDeveloperStudiogeneratedresourcescript.//#include"resource.h"#defineAPSTUDIO_READONLY_SYMBOLS/////////////////////////////////////////////////////////////////////////////////GeneratedfromtheTEXTINCLUDE2resource.//#inclu