Access Main Form from a DLL


2004-04-14 11:27:24 PM
cppbuilder111
Hello,
I want to make DLLs plugins for my application. I want the DLL to add a
new ToolButton to the main form of my app.
I tried that in the DLL:
extern "C" __declspec(dllexport) __stdcall InitDLL(TFormMain *Main);
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*
lpReserved)
{
return 1;
}
//--------------------------------------------------------------------------
-
__stdcall InitDLL(TFormMain *Main){
TToolButton *NewButton;
Main->Caption="hello";
NewButton=new TToolButton(Main->ToolBar);
NewButton->Parent=Main->ToolBar;
}
Then I called InitDLL from the Main Form using "ImpFuncDLL(this);"
In that case, the Caption of the Main Form change to "hello", but I get the
error "Impossible to affect TFont to TFont after
"NewButton->Parent=Main->ToolBar;".
So I think I'm not using the right thing to do what I want to do.
Is somebody already make something like that ?