diff options
author | George Hazan <ghazan@miranda.im> | 2018-04-19 18:17:25 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-04-19 18:17:25 +0300 |
commit | 2dd3e220e4c783a5454d763b01d56e71042644f2 (patch) | |
tree | 3bc72825fdc8a981e0cf5af155fea98c305b6ab0 /src | |
parent | 198fa4f35166d05fa513658c30f4a0bc6ab5a733 (diff) |
CallObjectEventHook: new function to call the event hook of the specified object
Diffstat (limited to 'src')
-rw-r--r-- | src/mir_core/src/mir_core.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/mir_core64.def | 1 | ||||
-rw-r--r-- | src/mir_core/src/modules.cpp | 28 |
3 files changed, 30 insertions, 0 deletions
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index 6e7bf951ce..2d117035ea 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1066,3 +1066,4 @@ IsTerminalDisconnected @1245 ??0CCtrlLabel@@QAE@PAVCDlgBase@@H@Z @1256 NONAME
??1CCtrlLabel@@UAE@XZ @1257 NONAME
??_7CCtrlLabel@@6B@ @1258 NONAME
+CallObjectEventHook @1259
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 748925cc79..98e8fb7ca2 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1066,3 +1066,4 @@ IsTerminalDisconnected @1245 ??0CCtrlLabel@@QEAA@PEAVCDlgBase@@H@Z @1256 NONAME
??1CCtrlLabel@@UEAA@XZ @1257 NONAME
??_7CCtrlLabel@@6B@ @1258 NONAME
+CallObjectEventHook @1259
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index a57f0d19ea..707cf91523 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -191,6 +191,34 @@ MIR_CORE_DLL(int) CallPluginEventHook(HINSTANCE hInst, HANDLE hEvent, WPARAM wPa return 0; } +MIR_CORE_DLL(int) CallObjectEventHook(void *pObject, HANDLE hEvent, WPARAM wParam, LPARAM lParam) +{ + THook *p = (THook*)hEvent; + if (p == nullptr || pObject == nullptr) + return -1; + + mir_cslock lck(p->csHook); + for (int i = 0; i < p->subscriberCount; i++) { + THookSubscriber* s = &p->subscriber[i]; + if (s->object != pObject) + continue; + + int returnVal; + switch (s->type) { + case 3: returnVal = s->pfnHookObj(s->object, wParam, lParam); break; + case 4: returnVal = s->pfnHookObjParam(s->object, wParam, lParam, s->lParam); break; + default: continue; + } + if (returnVal) + return returnVal; + } + + if (p->subscriberCount == 0 && p->pfnHook != nullptr) + return p->pfnHook(wParam, lParam); + + return 0; +} + static int CallHookSubscribers(THook *p, WPARAM wParam, LPARAM lParam) { if (p == nullptr) |