The window's WNDPROC is bound to MessageRouter.proc which calls the window's __handle_message() method which calls the WM_PAINT() method or the on_paint() method. If you're using CairoPanel, that descends from BitmapPanel which defines the on_paint() method. Hope this helps.
Although you already declined, I must bring back wxlua.
There is a fine and well maintained github repo at https://github.com/pkulchenko/wxlua (for Win/Linux/OS-X).
I'm using it as it is bundled with ZeroBrane Studio. The wx binding from ZBS plays well together with bin/mingw32/luajit.exe, but with bin/mingw64/luajit.exe I get errors (wx.dll is no valid win32 application). So I'd need a 64bit dll.
Sorry for pushing this thread, but I had a suggestion which would be quite handy if it was implemented on mgit.
mgit compiling Lua code into a dynamic libraries.
I believe there are several ways to implement this; pushing the Lua functions being exposed into some library, expose them as FFI callbacks, looking up for the functions on the global environment, etc. And having a automatic wrapper which tell what functions are allowed to be exported.
The result may come into a slow implementation but at least there's the possibility to rely on being able to actually develop alternative dynamic libraries for software that doesn't support Lua or LuaJIT, which is much more simple than compiling code on some older low level programming languages (C/C++).