Musze zrobic program ktory zlicza liczne klikniec prawym i lewym przyciskiem myszki.Ale problem tkwi w tym iz mimo ze zalozylem globalnego hooka to dalej poza forma nie zlicza ilosci klikniec?
Wie ktos gdzie popelniam blad?
tu linkt do calego projektu ttp://www.odzi.kgb.pl/j.zip

[code]#include <vcl.h>
#pragma hdrstop
#include <windows.h>
#include <fstream.h>
#include "dynamicfunction.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)
// Global variables
int x=0;
int y=0;

LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam);
HOOKPROC AdressMouseProc = {(FARPROC)MouseProc} ;

bool IsInRect=false;
HHOOK HookHandle;
HINSTANCE DllInstance;

//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
DllInstance=hinst;
return 1;
}
//---------------------------------------------------------------------------
bool InstallMouseHook(HINSTANCE hs)
{
if(hs){
if(!AdressMouseProc)
MessageBox(NULL, "Could not set the mouse hook.", "Hook FAILURE", MB_OK);
else{
DllInstance=hs;
// ShowMessage("To jest komunikat z biblioteki DLL\n");
HookHandle=SetWindowsHookEx(WH_MOUSE,(FARPROC)AdressMouseProc,DllInstance,0);
}

}
else
MessageBox(NULL, "The HINSTANCE is null", "What", MB_OK);
} //
//---------------------------------------------------------------------------
bool RemoveMouseHook()
{
// ShowMessage("To jest komunikat z biblioteki DLL\n");
ShowMessage("Captured left mouse button DOWN" + IntToStr(x));
ShowMessage("Captured rigt mouse button DOWN" + IntToStr(y));
if(UnhookWindowsHookEx(HookHandle)==0)
{
return false;
}
else return true;
}
//---------------------------------------------------------------------------
LRESULT CALLBACK MouseProc(int ncode, WPARAM wParam, LPARAM lParam)
{ //

  • if (!HookHandle) * Another process started, fill in the values
    //HookHandle = getHook();
    //ShowMessage("To jest komunikat z biblioteki DLL\n");
    if (ncode<0)
    {
    return CallNextHookEx(HookHandle,ncode,wParam,lParam);
    }
    LPMOUSEHOOKSTRUCT mouseCoords; // This is how you access the coordinates of the click
    char num[100];
    if (wParam == WM_LBUTTONDOWN)
    { sprintf(num, "Captured RIGHT mouse button");
    x++;

    } // End the if
    else if (wParam == WM_RBUTTONUP)
    { sprintf(num, "Captured RIGHT mouse button");
    y++;

    } // End the if
    // End the if

    return CallNextHookEx(HookHandle,ncode,wParam,lParam);
    }