Remy Lebeau (TeamB) wrote:
Thanks for the quick response.
> What is the exact linker error? You need to be more specific.
I needed extern "C" for the delphi side to see it. (solved).
>
>> TForm *GetTForm1() { if (Form1==0) Form1 = new TForm1(Form1);
>> return Form1;
I read that Delphi has everything by reference so it's changed to:
TForm & WINAPI _export GetTForm1() {
if (Form1==0) Application->CreateForm(__classid(TForm1), &Form1);
return *Form1;
}
}
>
> You are passing the NULLified Form1 pointer as the Owner of the TForm1
> instance you are trying to create for the Form1 pointer. If you don't want
> the new form to have an Owner, then specify NULL explicitally instead:
>
> TForm *GetTForm1()
> {
> if (Form1==NULL)
> Form1 = new TForm1(NULL);
> return Form1;
> }
Not the intent in this case, once the form is created it shouldn't go
away so it's owner should be the application. However this is good to
know anyways.
> Now, with that said - I would suggest moving the body of GetTForm() into the
> form's .cpp file instead of having it inlined in the header file:
OK, done.
new code is (inside unit1.cpp)
extern "C" {
TForm & WINAPI _export GetTForm1() {
if (Form1==0) Application->CreateForm(__classid(TForm1), &Form1);
return *Form1;
}
}
Thanks for your help!