1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
//---------------------------------------------------------------------------
#include <windows.h>
#pragma hdrstop
// Exported functions
extern "C" __declspec(dllexport)bool InstallMouseHook();
extern "C" __declspec(dllexport)bool RemoveMouseHook();
// Declarations
LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam);
// Global variables
HHOOK HookHandle;
HINSTANCE DllInstance;
bool IsInRect=false;
QList<QList<QList<QAction *>>> Menus;
QRect Rect1;
//---------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
DllInstance=hinst;
return 1;
}
//---------------------------------------------------------------------------
bool InstallMouseHook()
{
HookHandle=SetWindowsHookEx(WH_MOUSE,
reinterpret_cast<HOOKPROC>(MouseProc),DllInstance,0);
if (HookHandle==NULL)
{
MessageBox(0,"bali balo","Whatever",MB_OK | MB_ICONEXCLAMATION);
return false;
}
else return true;
}
//---------------------------------------------------------------------------
bool RemoveMouseHook()
{
if(UnhookWindowsHookEx(HookHandle)==0)
{
MessageBox(0,"balo bali","Whatever",MB_OK | MB_ICONEXCLAMATION);
return false;
}
else return true;
}
//---------------------------------------------------------------------------
void SendArray(QList<QList<QList<QAction * >>>tab)
{
Menus = tab;
}
//---------------------------------------------------------------------------
LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam)
{
if (code<0)
{
return CallNextHookEx(HookHandle,code,wParam,lParam);
}
QDesktopWidget *Bureau= new QDesktopWidget();
int x = Bureau->primaryScreen();
Rect1 = Bureau->availableGeometry(x);
QRect *Rect2 = new QRect(Rect1.x(),0,1,1);
QRect *Rect3 = new QRect(0,0,200,200);
POINT MousePos;
GetCursorPos(&MousePos);
MessageBox(0,"dll marche ","Whatever",MB_OK | MB_ICONEXCLAMATION);
HWND hWndUnder =WindowFromPoint(MousePos);
if ( hWndUnder == NULL)
{
if ( Rect3->contains(MousePos.x,MousePos.y))
{
MessageBox(0,"dans le rectangle","Whatever",MB_OK | MB_ICONEXCLAMATION);
}
return CallNextHookEx(HookHandle,code,wParam,lParam);
}
//--------------------------------------------------------------------------- |