lua-users home
lua-l archive

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


Hi all.
There are several finished GUI-blocks(frames, panels, dialogs) as dll. I need link each other all of them to data can pass from one component to another.
I built small project, where use C++-Lua binding by SWIG and wxWidgets GUI. The following listings of modules which I used:
swig_wrap.i:
Code:
%module MyModule
%{
#include "MyModule.h"
%}


MyModule.h:
Code:
#include <wxCommon.h>

void OpenDialog(void* frame);
void HelloWorld();


MyModule.cpp:
Code:
#include "MyModule.h"
#include "windows.h"

void HelloWorld() {MessageBox(NULL,"Hello","World",MB_OK);}
void OpenDialog (void* frame) {
    wxWindow *wxframe = (wxWindow *) frame;
    wxFileDialog *fd = new wxFileDialog(wxframe); fd->ShowModal();
}


script.lua:
Code:
package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;"
require("wx")

frame = wx.wxFrame( wx.NULL, wx.wxID_ANY, "wxLua Frame",
wx.wxDefaultPosition, wx.wxSize(450, 450),
wx.wxDEFAULT_FRAME_STYLE );

package.cpath = "MyModule.dll"
require("MyModule")
MyModule.HelloWorld();

frame:Show();
MyModule.OpenDialog(frame);

print("OK")
wx.wxGetApp():MainLoop()


Run command:
Code:
lua script.lua

MyModule.HelloWorld() work fine, but MyModule.OpenDialog(frame) crashes. What do I need to fix?