diff options
author | George Hazan <ghazan@miranda.im> | 2017-08-08 12:18:11 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-08-08 12:18:11 +0300 |
commit | 54d93d2c1ae60d2205476cc08ad356fc7bbd13e0 (patch) | |
tree | d2511407730733583156eab9c7a840b1e4fb336e /src | |
parent | fc8c1d39c4955db131d423a9930f5da878d10f9e (diff) |
HookTemporaryEvent - new function that executes an event handler immediately if the event is missing
usable to hook events that disappear after being used
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 | 24 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index f5037de864..8a8e4df230 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -1050,3 +1050,4 @@ CallFunctionSync @1170 ?Hide@CDlgBase@@QAEXXZ @1238 NONAME
?Resize@CDlgBase@@QAEXXZ @1239 NONAME
Utils_IsRtl @1240
+HookTemporaryEvent @1241
diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 31edd2dbea..f188b5b51d 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -1050,3 +1050,4 @@ CallFunctionSync @1170 ?Hide@CDlgBase@@QEAAXXZ @1238 NONAME
?Resize@CDlgBase@@QEAAXXZ @1239 NONAME
Utils_IsRtl @1240
+HookTemporaryEvent @1241
diff --git a/src/mir_core/src/modules.cpp b/src/mir_core/src/modules.cpp index c6908e723d..ae7cd45f1e 100644 --- a/src/mir_core/src/modules.cpp +++ b/src/mir_core/src/modules.cpp @@ -332,6 +332,30 @@ MIR_CORE_DLL(HANDLE) HookEventObjParam(const char *name, MIRANDAHOOKOBJPARAM hoo return HookEventInt(4, name, (MIRANDAHOOK)hookProc, object, lParam); } +MIR_CORE_DLL(HANDLE) HookTemporaryEvent(const char *name, MIRANDAHOOK hookProc) +{ + mir_cslockfull lck(csHooks); + + int idx; + if ((idx = hooks.getIndex((THook*)name)) == -1) { + lck.unlock(); + hookProc(0, 0); + return NULL; + } + + THook *p = hooks[idx]; + p->subscriber = (THookSubscriber*)mir_realloc(p->subscriber, sizeof(THookSubscriber)*(p->subscriberCount + 1)); + + THookSubscriber &s = p->subscriber[p->subscriberCount]; + memset(&s, 0, sizeof(THookSubscriber)); + s.type = 1; + s.pfnHook = hookProc; + s.hOwner = GetInstByAddress(hookProc); + + p->subscriberCount++; + return (HANDLE)((p->id << 16) | p->subscriberCount); +} + MIR_CORE_DLL(HANDLE) HookEventMessage(const char *name, HWND hwnd, UINT message) { mir_cslock lck(csHooks); |