home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 2002 April
/
VPR0204A.ISO
/
OLS_XP
/
WHEELLAYERED
/
WheelLayered.lzh
/
WheelLayeredSrc.lzh
/
WheelLayered
/
WheelLayeredDll.c
< prev
next >
Wrap
C/C++ Source or Header
|
2001-10-16
|
2KB
|
70 lines
//--------------------------------------------------------
#include <windows.h>
#include <windowsx.h>
#include <zmouse.h>
#include "WheelLayered.h"
#define PUSHED 0x8000
#pragma data_seg(".sdata")
HINSTANCE DLLInst = NULL;
HHOOK hHook = NULL;
HWND hPostWnd = NULL;
#pragma data_seg()
LRESULT CALLBACK GetMsgProc(int, WPARAM, LPARAM);
BOOL SetHook(HWND);
VOID FreeHook(VOID);
//--------------------------------------------------------
BOOL WINAPI DllMain (HINSTANCE hInstance, DWORD fdwReason, LPVOID lpvReserved)
{
DLLInst = hInstance;
return TRUE;
}
//--------------------------------------------------------
BOOL SetHook(HWND hWnd)
{
hHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, DLLInst, 0);
if(hHook == NULL){
MessageBox(NULL, "Hook Error!", APP_NAME, MB_OK);
return FALSE;
}
hPostWnd = hWnd; // メインのhWnd保存
return TRUE;
}
//--------------------------------------------------------
VOID FreeHook(VOID)
{
if(hHook != NULL){
UnhookWindowsHookEx(hHook); // Hook解除
hHook = NULL;
}
}
//--------------------------------------------------------
LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
SHORT sState;
PMSG pMsg;
if(nCode == HC_ACTION){
pMsg = (PMSG)lParam;
switch(pMsg->message){
case WM_MOUSEWHEEL: // Wheel
sState = GetKeyState(VK_RBUTTON);
if(sState & PUSHED){ // 右押し
if((short)HIWORD(pMsg->wParam) < 0) // 回転方向
PostMessage(hPostWnd, WM_USER, (WPARAM)FALSE, 0);
else
PostMessage(hPostWnd, WM_USER, (WPARAM)TRUE, 0);
}
break;
}
}
return(CallNextHookEx(hHook, nCode, wParam, lParam));
}