Mawg
Mawg

Reputation: 40140

Can I show a form in a DLL?

I would like to show a form (modally) in a COM DLL (as a user prompt). The DLL methods will eventually be invoked by some JavaScript in the browser (yeuck, but not my choice & can't be changed).

However, when I invoke the DLL method from my Delphi test program, I get an access violation.

Can I do what I am trying to do?

Upvotes: 1

Views: 1313

Answers (1)

David Heffernan
David Heffernan

Reputation: 612964

It's no problem at all. Perhaps you are relying on auto-create for your forms. That only happens in an EXE project. If my guess is correct you'll have a global variable of type TMyForm that is never initialized.

You need something like this:

var
  MyForm: TMyForm;//local variable
....
MyForm := TMyForm.Create(nil);
try 
  MyForm.ShowModal;
finally
  MyForm.Free;
end;

Upvotes: 3

Related Questions