hi agian. I afraid what i trie to do is not possible tha easy, but nevertheless, here i go.
i pack a class into a dll. i give the dll a function to retrive an object of that class. like this: (all is pure juce here)
class Module: privat Component{
Module(ModuleContainer*parent);
~Module();
...
...
}
__declspec( dllexport ) Module* getAnObject(ModuleContainer*parent){
return new Module(parent);
}
and in the Host i use Windows functions to load the dll manually(i wan tto make plug in architecture), the rest is pure juce code.
typedef Module* (*getModuleFromDLL_)(ModuleContainer* container);
Module* loadModule(){
Module* newModule;
HINSTANCE hinstLib;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
getModuleFromDLL_ moduleGetter;
hinstLib = LoadLibrary(TEXT("Module.dll"));
if (hinstLib != NULL)
{
moduleGetter = (getModuleFromDLL_) GetProcAddress(hinstLib, "getModuleFromDLL");
if (NULL != moduleGetter) {
newModule = moduleGetter(container);
}
else AlertWindow::showMessageBox(AlertWindow::WarningIcon,"cantgetProc","");
fFreeResult = FreeLibrary(hinstLib);
}
else AlertWindow::showMessageBox(AlertWindow::WarningIcon,"cant load file","");
if (! fRunTimeLinkSuccess)
printf("Message via alternative method\n"); */
return newModule;
}[/code]
the loading of the dll and proc seems to work fine, but if i try to set the bounds of the retrived object i get an jassert that the loaded comp is in a different message loop, so its not thread safe to manipulate it from host.
[code]Module* newModule = loadModule(moduleType);
const MessageManagerLock mmLock;//tested without too
newModule->setBounds(x,y,100,50);// <-- jassert in this fiunction()
...
...
// if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
i end here
is there a way around? is this because the dll must spawn another thread/process?
i called initialiseJuce_GUI ( ) after getting the “juce not initialised” jasserts in the dllmain() and such (i copied the whole main from vstWrapper), and after i’ve seen this is nessecary it was almost clear that the class gets not just loaded, no, it creates a whole new process.
(i’m totally new to dll, actualy my first step, so please bear with me if i say something dump).
so can’t i just append the comp to the other comps (as i child, like it is a class like the one linked at compile time) and the main message loop? can i make the calls using a MessageManagerLock (seemed not to work, and would be tedious)?
please say there is an easy solution, from what i’ve read now it seems like there isn’t such a thing.
thanks in advance
D3CK