lua-users home
lua-l archive

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


You can store the handle of the thread in the _G[ ] table in Lua when you created a thread.
The handle is a ID number (or a string) of the thread.
Then in C, you can call the func getThread(lua_number ID) to pass the ID to Lua and
get the lua_State of the thread.
 




On 12/20/06, Cloud Wu <cloudwu@163.com> wrote:
Hello ,

      When I wrote a windows application embedding lua, I want to call
      some lua code in WinProc . Like this :

-------------------------------
static LRESULT CALLBACK
WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
        switch (iMessage) {
        case WM_MOUSEMOVE:
             /* call some lua function */
             ...
---------------------------------

      But in WndProc , I can't get the running thread in lua .
      I can store the main lua state in a global variable, but the
      main lua state may not be the running thread. And I have no way
      to pass the L into the WndProc .

      How to get the current thread from the main lua state in C ?

--
Best regards,
Cloud                          mailto:cloudwu@163.com
            http://blog.codingnow.com

[失去, 总令人舍不得, 但痛苦并不来自于失去, 而是来自于我们不肯放手]





--
Linker M Lin
linkerlin88@gmail.com