Sign in to follow this  
Lust

Need help for wxWidgets and a DLL

Recommended Posts

Lust    122
Hello! I am having a problem which I cannot solve for nearly a month. Some code follows: class cEditor { .... wxFrame *m_MainFrame; .... }; typedef void (*PlugInReg)( cEditor * ); //in the DLL project: // the actual <cEditor *Editor> is declared in the project loading the DLL extern "C" declspec (dllexport) void PlugInRegister( cEditor *Editor ) { wxMenu *menu = new wxMenu(); menu->Append( wxID_ANY, "Some..." ); Editor->m_MainFrame->m_MenuBar->Append( menu, "DLL Appended" ); } //in the main project cEditor *Editor; void MyApp::OnInit(...) { // Editor is new'd // Editor->m_MainFrame is initialized // pseudo plug-in is loaded here HINSTANCE *hDLL1 = LoadLibrary("..."); PlugInReg RegFunc = (PlugInReg)GetProcAddress( hDLL1, "PlugInRegister" ); if( RegFunc ) { RegFunc( Editor ); } } Now this is the code, the program runs successfuly and the menu is appended:) BUT, when I close the app, wxWidgets f*cks up and throws an exception that it cannot find and destroy the string of the menu caption, i.e. "DLL Appednded" or "Some...". Is it because the loaded library is freed before deallocation of the menu memory? I have taken a look in some samples for appending a menu in WX from a DLL but they are not easily comprehensible and i am not sure that they are for the same purpose. Please help me!:)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this