#include "WndProcEater.h" static HWND hWndEaten = 0; static WNDPROC eatenWndProc = 0; static ExtraWndProc* extraProcs = 0; static int numExtraProcs = 0; void ReleaseExtraProc(ExtraWndProc proc) { for (int i=0; i res) res = res2; } } if (res != NO_WND_PROC) { if (out == WM_DESTROY) { ReleaseEatenProc(); } if (res == CONTINUE_BLISSFULLY) out = CallWindowProc(eatenWndProc, hWnd, uMsg, wParam, lParam); else if (res == USE_DEFAULT_WND_PROC) out = DefWindowProc(hWnd, uMsg, wParam, lParam); } return out; } int EatWndProc(HWND hWnd, ExtraWndProc proc) { if (hWnd != hWndEaten) { ReleaseEatenProc(); eatenWndProc = (WNDPROC) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR)OverrideWndProc); // ??? if (!eatenWndProc) return 0; hWndEaten = hWnd; } extraProcs = (ExtraWndProc*) realloc(extraProcs, sizeof(ExtraWndProc)*(numExtraProcs+1)); extraProcs[numExtraProcs++] = proc; return 1; }