I want use wxWidgets in dll. I had seen the article http://wiki.wxwidgets.org/Creating_A_DL ... pplication
I use wxDec-C++ to create a new dll project. I copy the code and then compile but it don't work !! Could any body help me?? It is very important for me!! Thanks a lot!!
Help!!! How to use wxWidgets in dll ? Topic is solved
OK.I use wxDev-C++ and create a new dll project. Then i copy the code that finded in the forum. When i compile it will be some errors.
It is the code ,Please help me!
It is the code ,Please help me!
Code: Select all
/* This is the dll.h */
#include <wx/wx.h>
#ifdef __WXMSW__
#ifdef HELPER_EXPORTS
#define HELPER_API __declspec(dllexport)
#else
#define HELPER_API __declspec(dllimport)
#endif
#else // clever platforms do not need this
#define HELPER_API
#endif
class HelperOption : public wxWindow
{
public:
HelperOption(wxWindow* parent);
~HelperOption();
private:
// any class wishing to process wxWidgets events must use this macro
DECLARE_EVENT_TABLE()
};
HelperOption* options;
extern "C" HELPER_API LONG HelperProc(wxWindow* wnd);
Code: Select all
/* The dllmain.cpp */
#include "dll.h"
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
int argc = 0;
char **argv = NULL;
if (!wxEntryStart(argc, argv) || !wxTheApp || !wxTheApp->CallOnInit() )
return FALSE;
}
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
wxEntryCleanup();
break;
}
return TRUE;
}
extern "C" HELPER_API LONG HelperProc(wxWindow* wnd)
{
options = new HelperOption(wnd);
}
HelperOption::HelperOption(wxWindow* parent)
: wxWindow(parent, wxID_ANY, wxPoint(0,0), wxDefaultSize, wxBORDER_RAISED | wxTAB_TRAVERSAL)
{
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
topsizer->Add(new wxStaticText(this, wxID_ANY, "Helper Options", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE));
//... and so forth with the rest of the controls.
}
- Attachments
-
- The error information,Idont know how to do.
- error_information.jpg (26.8 KiB) Viewed 2695 times
When showing compiler output, please give full output, not just blind image...
When compiling, add option -DHELPER_EXPORTS. And fix the line below:
When compiling, add option -DHELPER_EXPORTS. And fix the line below:
Code: Select all
topsizer->Add(new wxStaticText(this, wxID_ANY, wxString (wxT ("Helper Options")), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE));
Everything requires a line of code.
I follow this article:
http://forums.wxwidgets.org/viewtopic.php?p=5964#5964
I use mingw.The code need to include "wx/msw/private.h". DllMain function also need to be exported,else it doesn't work.The strings need to add "_T()".
And then it work!
Thanks a lot!
http://forums.wxwidgets.org/viewtopic.php?p=5964#5964
I use mingw.The code need to include "wx/msw/private.h". DllMain function also need to be exported,else it doesn't work.The strings need to add "_T()".
And then it work!
Thanks a lot!