/*--------------------------------------------------------*/
/* (Microsoft Visaul c++ 1.5) Copyright  1995 by          */
/*              Microtek ShangHai Co.                     */
/*           EasyPack / SLD Tutorial system               */
/*           Tutorial mouse hook DLL Module               */
/*              by hu wei  1995.10                        */
/*                  TMouse.cpp                            */
/*--------------------------------------------------------*/

#include <windows.h> 
#include "tmouse.h"

HANDLE	hInstance;		// Global instance handle for  DLL
BOOL     bMouse=0;
HOOKPROC hMouseFilterPro=0;
HHOOK    hMouseHook=0;
     
int _export CALLBACK _WEP (int bSystemExit);
int _export CALLBACK LibMain(HANDLE hModule,
                        WORD wDataSegment,
                        WORD wHeapSize,
                        LPSTR lpszCmdLine);

DWORD  _export CALLBACK  HookProc(int nCode,
                                 WPARAM wParam,
                                 LPARAM lParam);
//--------------------------------------------------------------

int _export CALLBACK LibMain(HANDLE hModule,
                        WORD wDataSegment,
                        WORD wHeapSize,
                        LPSTR lpszCmdLine)

{
 if(wHeapSize!=0)
   UnlockData(0);
 hInstance = hModule;
 return 1;  
} 
    
#pragma alloc_text(FIXEDSEG, _WEP)
//---------------------------------------------------------------------------
// WEP
//---------------------------------------------------------------------------
int _export CALLBACK _WEP (int bSystemExit)
{
    return(1);
}
                 
//---------------------------------------------------------------------------
// Set Mouse
//---------------------------------------------------------------------------
void _export FAR PASCAL SetMouse(BOOL mouse)
{
  bMouse=mouse;
} 


//---------------------------------------------------------------------------
// InstallSysMsgFilter
//
// Install / Remove Filter function for the WH_SYSMSGFILTER
//
//---------------------------------------------------------------------------
int __export CALLBACK InstallFilter (int nCode )
{

  if ( nCode ) 
     {
	   hMouseHook = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)HookProc , hInstance,NULL);
     }
  else 
     {
	   UnhookWindowsHookEx(hMouseHook);
     } 
  return 1;   
}

                 
DWORD _export CALLBACK  HookProc(int nCode,
                                  WPARAM wParam,
                                  LPARAM lParam)
{       
 if(!bMouse)
   return 0;
 return 0;  
 //return CallNextHookEx(hMouseHook,nCode,wParam,lParam);
}                                             
                       