#include "waitcurs.h" #include static HINSTANCE __far hinstDLL; static HHOOK __far hook=NULL; static HCURSOR __far hWaitCursor; static HTASK __far htaskWait=NULL; static HWND __far hwndDesktop=NULL; #pragma pack(1); struct hookMSG { LPARAM lParam; WPARAM wParam; UINT uMsg; HWND hWnd; }; #pragma pack(); LRESULT CALLBACK MyCallWndProc(int code, WPARAM wParam, LPARAM lParam) { if(code>=0) { hookMSG __far *msgp = (hookMSG __far *)lParam; if(msgp->uMsg==WM_SETCURSOR && (LOWORD(msgp->lParam)==HTCLIENT || LOWORD(msgp->lParam)==HTCAPTION) && GetCapture()==NULL && GetWindowTask(msgp->hWnd)==htaskWait && msgp->hWnd!=hwndDesktop) { SetCursor(hWaitCursor); msgp->uMsg = WM_NULL; return 0; } } return CallNextHookEx(hook,code,wParam,lParam); } BOOL CALLBACK __export BeginWaitCursor(void) { if(hook!=NULL) return FALSE; htaskWait = GetCurrentTask(); hook = SetWindowsHookEx(WH_CALLWNDPROC, (HOOKPROC)MyCallWndProc, hinstDLL, NULL ); if(hook==NULL) return FALSE; else return TRUE; } BOOL CALLBACK __export EndWaitCursor(void) { if(hook==NULL) return FALSE; return UnhookWindowsHookEx(hook); } int CALLBACK LibMain(HINSTANCE hinst, WORD, WORD, LPSTR) { hinstDLL=hinst; hwndDesktop=GetDesktopWindow(); struct dosdate_t date; _dos_getdate(&date); if(date.month!=12) hWaitCursor = LoadCursor(hinst,MAKEINTRESOURCE(1)); else hWaitCursor = LoadCursor(hinst,MAKEINTRESOURCE(2)); if(hWaitCursor==NULL) hWaitCursor = LoadCursor(NULL,IDC_WAIT); return 1; } extern "C" int CALLBACK __export WEP(int nExit) { if(nExit!=WEP_SYSTEM_EXIT) { if(hook) UnhookWindowsHookEx(hook); if(hWaitCursor) DestroyCursor(hWaitCursor); } return 1; }