Hi,
I am writing an application using the JUCE framework, and it is a most pleasant experience. I am now facing a bit of a challenge:
I need to retrieve a pointer to a Component from a DLL, and display this Component in my main application.
This is mostly fine. I can easily compile the DLL, and it is loaded with the platform specific loader function, and the getComponent() entrypoint is found and called, and I end up with a valid component pointer. The DLL Component is created using the jucer application and contains graphics and sub-components.
At first, attempting to addAndMakeVisible the component from the DLL would crash my app; this was solved by making the initJuceGui() call in the DLL onload() function. For those that are interested, in linux you can do that like this:
#ifdef __cplusplus
extern "C" {
#endif
void __attribute__ ((constructor)) onLoad(void);
void __attribute__ ((destructor)) onUnload(void);
#ifdef __cplusplus
}
#endif
// Called when the library is loaded and before dlopen() returns
void onLoad(void)
{
initialiseJuce_GUI();
}
// Called when the library is unloaded and before dlclose()
// returns
void onUnload(void)
{
shutdownJuce_GUI();
}
Now, this means that the component in the DLL is using a different static MessageManager, etc, etc. Which brings me to the problem in hand: the component displays properly, but is not interactive - clicking on controls does not do anything. I figure this is because my main application is not feeding it messages (why would it?).
The component from the DLL is deliberately ‘hosted’ in a component in my application, so I was aiming to pass all messages in the parent (application) component to the child (dll) component. But I dont know how to do this, or whether it would even work.
Also, since the handleMessage() member of Component is overloaded from MessageListener which is inherited as protected, I can’t overload it, so I dont know the way into the message system even if this is a good idea.
Can anyone help?