home *** CD-ROM | disk | FTP | other *** search
- #include <windows.h>
- #include <process.h>
-
- BOOL WINAPI _DllMainCRTStartup(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
- {
- return TRUE;
- }
-
-
- #pragma data_seg("ShrdSeg")
- HHOOK hHook=NULL;
- int state=0;
- HWND hwndParent=NULL;
- #pragma data_seg()
-
- __declspec( dllexport ) int get()
- {
- int n=state;
- state=0;
- return n;
- }
-
- __declspec( dllexport ) void quit()
- {
- if (hHook) UnhookWindowsHookEx(hHook);
- hHook=0;
- }
-
- __declspec( dllexport ) void init(HWND hwnd, HINSTANCE hinst)
- {
- hwndParent=hwnd;
- hHook = SetWindowsHookEx(WH_GETMESSAGE,(HOOKPROC)
- GetProcAddress(hinst,"_Hook1Proc@12"),
- hinst,0);
- }
-
- __declspec( dllexport ) LRESULT CALLBACK Hook1Proc(int nCode,WPARAM wParam,LPARAM lParam)
- {
- MSG *msg=(MSG *)lParam;
- if (
- msg->message == WM_COMMAND ||
- msg->message == WM_ACTIVATE ||
- msg->message == WM_NCACTIVATE ||
- msg->message == WM_SETFOCUS ||
- msg->message == WM_ERASEBKGND ||
- msg->message == WM_PAINT ||
- msg->message == WM_LBUTTONDOWN ||
- (msg->message == WM_KEYDOWN && msg->wParam == VK_RETURN) ||
- 0)
- {
- int up=1;
- if (msg->message == WM_PAINT)
- {
- RECT r;
- GetUpdateRect(msg->hwnd,&r,FALSE);
- if ((r.right-r.left)*(r.bottom-r.top) < 4000)
- up=0;
- }
- if (up && msg->hwnd != hwndParent && GetParent(msg->hwnd) != hwndParent) state++;
- }
- return CallNextHookEx(hHook,nCode,wParam,lParam);
- }
-
-