Link to home
Start Free TrialLog in
Avatar of Avataris
Avataris

asked on

using forms in dll's

Hi,
I want to create a program, which is expandable using dll's.
My       Q1:      How can I put a form in a DLL?
      Q2:      How do I make the form visible?

I thought I had the answer by just exporting the form's object type. But, when I import, using getprocaddr, the object and call the form.create. I receive a Exception.

Example of my code:

Var Form1:TForm

 Handle := LoadLibrary('LIBFORMTEST.DLL');
  if Handle <> 0 then
  begin
    Form1 := GetProcAddress(Handle, 'TForm1');
    if @Form1 <> nil then
    begin
      Form1.Create(nil);
      Form1.Show;
    end;
  end;

The TForm1 is the exported object type in the DLL.

Anyone has any examples about forms in a dll, or anyone can tell me how to make this work?


Greetz.
  Avataris      
Avatar of ZifNab
ZifNab

I could answer this, but Epsylon got a nice demo, so wait for Epsylons demo
You can put such a function into your DLL:

function CreateForm : TForm;
begin
  Result := TForm.Create(nil);
end;

And call that func from your application as:

Var
  Form1:TForm
  Func : Pointer;

 Handle := LoadLibrary('LIBFORMTEST.DLL');
  if Handle <> 0 then
  begin
    Func := GetProcAddress(Handle, 'CreateForm');
    if @Func <> nil then
    begin
      Form1 := Func;
    end;
  end

I don't know if it will work, but you can try...
Yes, I've got I nice demo. Thanks Zif for refering to me.

Drop your email address here and I'll send it to you.
Epsylon,

When you read this, can you send me that demo, or post the code for it here, or something.  I'd be interested to see how you do it.

Stu.
mmm, still no notifactions... well, I've to check all these messages! Damn.

Stu, can you send an example as well?
Of course, Stu, your have sent me something a few week ago so it seems fair to me to send you something back. It's even about the same subject.   :o)

But you have to wait a few hours because I only have it at home.

Eps.
ASKER CERTIFIED SOLUTION
Avatar of simonet
simonet
Flag of Brazil 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
Avataris, do you want that demo or not?
Avatar of Avataris

ASKER

I'm sorry.. Have been busy lately....;(
Apologies.

Well, I've tried your suggestion, It works fine THX!..
Not as the way I wanted to but, this works oke for me too...

Have you placed your demo somewhere?

Maybe there are other users with doing the same project as I.

I want to create a modular wave studio. So that it can be used as
- A modular Synthesizer
- A Sampler
- And last but not least a Vocoder!

Greetz..
 Avataris
No I have not.