lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> But message process and create window may not in the same coroutine.
> For example, if you are calling UpdateWindow in a lua coroutine.
> UpdateWindow will call SendMessage(hWnd,WM_PAINT) , and this will call
> my WinProc . At this time, it needs coroutine's lua_State *L , not the
> lua_State at the time window created .

This is a common problem in some APIs. If you cannot store callback data
in WinProc, then the best you can do is to store the Lua state in a global
variable everytime you get in C from Lua, ie, everytime Lua calls C. I've
done that on a some occasions for error handling and other interrupts.
See my lalarm, lbc, lgdbm and lmapm. Look for LL.
--lhf