From: Steve M. <sm...@sm...> - 2012-05-02 00:53:00
|
Hello, I've managed to integrate wxLua into a DLL that my application uses. The DLL is purely there to provide script capabilities. When a user wants to run a script, the action ends up in the DLL which uses the following code: // luaControl constructor. luaControl is derived from wxWindow. luaControl::luaControl(wxWindow *parent, MINSTANCE mInst, wxMachPluginLuaApp *pluginApp, HMCPLUG id) { wxWindow::Create(parent, ID_LUAWIN); WXLUA_IMPLEMENT_BIND_ALL // OnInit() already called // wxLuaState::sm_wxAppMainLoop_will_run = false; m_wxlState = wxLuaState(this, wxID_ANY); } int luaControl::ExecuteScript(wxString &filename) { if (!m_wxlState.Ok()) { return(-1); } int rc = m_wxlState.RunFile(filename); if (rc != 0) { wxString emsg = wxlua_LUA_ERR_msg(rc); mcSetLastError(this->m_cid, (const char *)emsg.char_str()); return(rc); } while (m_wxlState.IsRunning()) ; return(rc); } This, at first, seems to work fine. The script will execute and show it's GUI window. Take minimal.wx.lua, for example. But when you are done playing with the script, you can't close its top level window! I seem to have painted myself into a corner. I think it has something to do with the fact that the application as a whole has multiple wxApp classes. One for the main GUI executable, one for a DLL that is the core of the application, and one for the scripting DLL. This is on Windows, for the moment, and wxWidgets is compiled into static libs which all modules link to. It feels like it is hooking the GUI executable's main loop instead of the script DLLs main loop. Is there any way to force wxLua to use a particular wxApp instance? Or am I barking up the wrong tree? Thanks, Steve |