Link to home
Start Free TrialLog in
Avatar of KentDRuddick
KentDRuddick

asked on

Writing to form in DLL

Hello,

I am not sure what I am doing wrong.

I have made a DLL.

Inside the DLL I have include a form and unit1. On the form is a Memo control.

My guess is I have some kind of scoping issue. I can create the form, show the form, but when I go to write in the Memo control the program crashes.

I have to fully qualify the Memo for intellisense to work. Form1.Memo1.Lines.add(s);

I am guessing that it is because once I leave the procedure that creates the form that the form is no longer recognized?

Can someone show me the proper way to create a form in a DLL and be able to write to a memo from procedures.

I have something along the lines of: (I just sketched this out.. probably not accurate on class names)

Procedure WriteMemo(s:string);
Begin
  Form1.memo1.lines.add(s);
End;

Procedure DoTheWork();
Var
  Form1 : TForm;
Begin
  Form1 := TForm.Create(nil)
  Form1.show;
 [code]
  writememo(string);
end;

I am calling DoTheWork from the Library unit.

Any help is appreciated.
Thanks
kent




ASKER CERTIFIED SOLUTION
Avatar of DragonSlayer
DragonSlayer
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
or, instead of local, you can make your Form1 to be global, so that both procedures are accessing the same Form1 variable. I think you might have 2 declarations of Form1 in your unit, one global and one local, hence the crash.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of KentDRuddick
KentDRuddick

ASKER


I split the points because both answers led me to my solution.

It was definitely a lack of understanding of the language and some creative programming on my part.

Thanks for the help.
Kent