wxPluginManager and wxPluginLibrary Topic is solved
-
- Super wx Problem Solver
- Posts: 466
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
-
- Knows some wx things
- Posts: 44
- Joined: Mon Mar 13, 2006 7:07 pm
- Location: Montevideo, Uruguay
1) What about the wxPluginLibrary and wxPluginManager classes? Where can I find the code for those?
2) Can I put this LoadPlugins() in the frame class (say, in a button) rather than in the wxApp class?
3)I'm developing with MVS6.0... where should I use the wxUSE_DYNLIB_CLASS ?
4)My dll is created out of a .h a .cpp and a .def files in a dll project... Should that be enough?
2) Can I put this LoadPlugins() in the frame class (say, in a button) rather than in the wxApp class?
3)I'm developing with MVS6.0... where should I use the wxUSE_DYNLIB_CLASS ?
4)My dll is created out of a .h a .cpp and a .def files in a dll project... Should that be enough?
Hi!
WXDIR/src/common/dynload.cpp
By the way: For wxPlugin* wxUSE_DYNAMIC_LOADER has to be defined.
But apart from having a "simpler" interface I don't see why you should use these in favor of wxDynamicLibrary.
Your DLL will have to export the relevant functions. You will need to link your DLL with wxWidgets, if the DLL uses wxWidgets which I guess it does.
WXDIR/include/wx/dynload.hfarocam wrote:1) What about the wxPluginLibrary and wxPluginManager classes? Where can I find the code for those?
WXDIR/src/common/dynload.cpp
Yes, there is nothing wxApp specific about this.farocam wrote:2) Can I put this LoadPlugins() in the frame class (say, in a button) rather than in the wxApp class?
Using the standard config you don't have to do anything, it's already defined. Have a look at WXDIR/include/wx/msw/setup.h.farocam wrote:3)I'm developing with MVS6.0... where should I use the wxUSE_DYNLIB_CLASS ?
By the way: For wxPlugin* wxUSE_DYNAMIC_LOADER has to be defined.
But apart from having a "simpler" interface I don't see why you should use these in favor of wxDynamicLibrary.
In general, yes.farocam wrote:4)My dll is created out of a .h a .cpp and a .def files in a dll project... Should that be enough?
Your DLL will have to export the relevant functions. You will need to link your DLL with wxWidgets, if the DLL uses wxWidgets which I guess it does.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
-
- Super wx Problem Solver
- Posts: 466
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
Woops! I guess I misunderstood the comments in the documentation for wxDynamicLibrary here. The project compiles ok without that define. Sorry about that.upCASE wrote:Using the standard config you don't have to do anything, it's already defined. Have a look at WXDIR/include/wx/msw/setup.h.farocam wrote:3)I'm developing with MVS6.0... where should I use the wxUSE_DYNLIB_CLASS ?
On another note, it seems that my LoadPlugins function wont work after all. I could have sworn it was working last night, but it
Re: wxPluginManager and wxPluginLibrary
[quote="farocam"]...
I
I
-
- Super wx Problem Solver
- Posts: 466
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
Here is another sample (at this point very, very loosely based on the original) that will hopefully be more helpful to you. The plugin consists of a simple panel with one text control. There are three parts: the library header, the library body, and the main application body.farocam wrote:If I send you a brief summary of my classes and the hello world method I wish to load in the app ... will you have time to check it? The thing is that my library loads fine and so does the GetSymbol function ...but I don't know how to access the plugin class object nor its methods ...
Here
-
- Super wx Problem Solver
- Posts: 466
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
Since you brought this up, I might as well explain a curious part in the library header:farocam wrote:nor its methods ...
Code: Select all
#include <wx/dynlib.h>
#include <wx/dynload.h>
#define ID_DEFAULT -1 // Default
class PluginBase : public wxPanel{
public:
virtual void SetParent(wxWindow* parent)=0;
};
class PanelPlugin : public PluginBase{
public:
DECLARE_DYNAMIC_CLASS(PanelPlugin)
void SetParent(wxWindow* parent);
protected:
wxTextCtrl *m_textCtrl1;
};
I think there might be even more to this topic. I can't get any example working and I suspect it's due to me linking to a static C runtime, nit the DLL one.
Anyway, when I find some time I'll see if I can create an example using a wxWidgets host and plugin that uses only wxDynamicLibrary and a simple general plugin interface that would allow the app the create an instance of the DLL classes without using the RTTI system.
Anyway, when I find some time I'll see if I can create an example using a wxWidgets host and plugin that uses only wxDynamicLibrary and a simple general plugin interface that would allow the app the create an instance of the DLL classes without using the RTTI system.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
-
- Knows some wx things
- Posts: 44
- Joined: Mon Mar 13, 2006 7:07 pm
- Location: Montevideo, Uruguay
New Pagodi,
Thanks for your time and your code. I've tried to add it into my projects and I have some doubts. I've built the dll, but some details in you aplication make me thinks it's not a real plug in:
PanelPlugin since my app would already be compiled, so I must be able to create that object without writine in code the name of the class.
Do you know how can I do this ?
Thanks!
Fabian
Thanks for your time and your code. I've tried to add it into my projects and I have some doubts. I've built the dll, but some details in you aplication make me thinks it's not a real plug in:
I wouldn't be able to do that if, say, for example I have my application working and I want to create a new plug in, would I? I mean that the host would already be compiled and I would not be able to modify it's code... That brings us to another detail:Code: Select all
#include //enter the name of the library header here
that's part of the LoadPlugIn() method. Again, I would not be able to writeCode: Select all
//constructor in other ways. PanelPlugin *object =(PanelPlugin*) wxCreateDynamicObject("PanelPlugin"); //Now that we have our panel object, we set it's parent the be the main form.
PanelPlugin since my app would already be compiled, so I must be able to create that object without writine in code the name of the class.
Do you know how can I do this ?
Thanks!
Fabian
-
- Knows some wx things
- Posts: 44
- Joined: Mon Mar 13, 2006 7:07 pm
- Location: Montevideo, Uruguay
Besides, the line
causes my application to crash with a fatal error...Code: Select all
object->SetParent(this);
-
- Super wx Problem Solver
- Posts: 466
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
All good points. I was trying to keep the example as simple as possible (and simply made a few mistakes). Technically what we should do is split the library headers like this.farocam wrote:New Pagodi,
Thanks for your time and your code. I've tried to add it into my projects and I have some doubts. I've built the dll, but some details in you aplication make me thinks it's not a real plug in:
I wouldn't be able to do that if, say, for example I have my application working and I want to create a new plug in, would I? I mean that the host would already be compiled and I would not be able to modify it's code... That brings us to another detail:Code: Select all
#include //enter the name of the library header here
that's part of the LoadPlugIn() method. Again, I would not be able to writeCode: Select all
//constructor in other ways. PanelPlugin *object =(PanelPlugin*) wxCreateDynamicObject("PanelPlugin"); //Now that we have our panel object, we set it's parent the be the main form.
PanelPlugin since my app would already be compiled, so I must be able to create that object without writine in code the name of the class.
Do you know how can I do this ?
Thanks!
Fabian
Generic plugin header:
Code: Select all
#include <wx/dynlib.h>
#include <wx/dynload.h>
class PluginBase : public wxPanel{
public:
virtual void SetParent(wxWindow* parent)=0;
};
Code: Select all
#include //enter the name of the generic plugin header here
#define ID_DEFAULT -1 // Default
class PanelPlugin : public PluginBase{
public:
DECLARE_DYNAMIC_CLASS(PanelPlugin)
void SetParent(wxWindow* parent);
protected:
wxTextCtrl *m_textCtrl1;
};
Code: Select all
change: #include //enter the name of the library header here
to: #include //enter the name for header for the panel plugin
Code: Select all
change: #include //enter the name of the library header here
to: #include //enter the name of the genaric plugin header here
and
change: PanelPlugin *object =(PanelPlugin*) wxCreateDynamicObject("PanelPlugin");
to: PluginBase *object =(PluginBase*) wxCreateDynamicObject("PanelPlugin");
-
- Super wx Problem Solver
- Posts: 466
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
Doh! It works for me. Try replacing all the code in the body of SetParent withfarocam wrote:Besides, the line
causes my application to crash with a fatal error...Code: Select all
object->SetParent(this);
Code: Select all
wxLogWarning("The method can be called successfully.");
-
- Super wx Problem Solver
- Posts: 466
- Joined: Tue Jun 20, 2006 6:47 pm
- Contact:
That would be great. IupCASE wrote:I think there might be even more to this topic. I can't get any example working and I suspect it's due to me linking to a static C runtime, nit the DLL one.
Anyway, when I find some time I'll see if I can create an example using a wxWidgets host and plugin that uses only wxDynamicLibrary and a simple general plugin interface that would allow the app the create an instance of the DLL classes without using the RTTI system.