Solved

components from DLL to a main Form HELP!!!

Posted on 1997-06-02
2
182 Views
Last Modified: 2010-04-06
Hello!
I have a problem that I could not resolve, grateful that will help me to solve it, Exists a form in my application that it is the main menu, and other forms of capture of datas that are in a DLL.
The problem is that the components of the form that exist them in the DLL want to put in a panel of the main menu form in order to don't have two activated forms.
There is attempt passing the main menu form or the Panel like parameter and change the parent propierity of the components, but it don't introduce me the components, although if it change of the form that meets in the DLL.

Like you could I make in order to solve the problem? and if you can sendme a examples of how to work with DLL's

thanks!

carlos@compac.com.mx
0
Comment
Question by:Charlie V
2 Comments
 
LVL 1

Accepted Solution

by:
ozzy earned 130 total points
ID: 1336759
In the dll, call a function called CreatePanel(Sender : TObject) where Sender would be Application.MainForm
Then in the procedure do something like this...

Procedure CreatePanel(Sender : TOBject);
VAR
Panel_One : TPanel;
Begin
PAnel_One := Tanel.Create(Sender);
..
....
end;

That should make the panel belong to the mainform because you are creating it dynamically and making the parent MAINFORM.  If you already have a form created, for example FORM1, in the dll, it's probably of type TFORM.  Just setup another one in that DLL of type TForm, for example Form2 and create it dynamically and assign the parent to MainForm.

This sound like something that you could do.

0
 

Author Comment

by:Charlie V
ID: 1336760
I been tyi to apply the example you but to the compile send me an error and is because TPanel accepts a parameter of TComponent type and not of TObject type.
Change the type of parameter and pass the compile process, but don't introduce the panel that believes in the DLL in the MainForm.

The one which I try to make is that a group of components that they meet in a DLL, all these assembled in a Panel are called from the MainForm (EXE) and they are viewed, I generate a class with all the components that I need in the DLL and I apply the example that you sent, apparently generate all the components but don't introduce it in the MainForm

here this the one which I made:

this in the DLL File

type
   TCalendar = class(TObject)
    Panel1 : TPanel;
    KSCalendar1: TKSCalendar;
    KSControlBar1: TKSControlBar;
    constructor Create(AOwner: TObject);
    destructor Destroy; override;
  private
  public
end;

var
  panCalendar : TCalendar;

procedure LoadCalendar(Sender: TObject); export;

implementation

procedure LoadCalendario(Sender: TObject);
var
  Panel_One : TPanel;
begin
  panCalendar := TCalendar.Create(Sender);
end;

constructor TCalendar.create(AOwner: TObject);
begin
   inherited Create;
   panel1 := TPanel(AOwner);
   KSCalendar1:= TKSCalendar.Create(Panel1);
   KSControlBar1:= TKSControlBar.Create(Panel1);
end;

destructor TCalendar.Destroy;
begin
   panel1.free;
   KSCalendar1.Free;
   KSControlBar1.Free;
   inherited Destroy;
end;


and this in de EXE File

procedure LoadCalendar(AOwner: TComponent);

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation

uses uniCalendasinforma;

{$R *.DFM}

procedure LoadCalendar; external 'caldll' index 1;

procedure TForm1.FormCreate(Sender: TObject);
begin
   LoadCalendar(Application.MainForm);
end;

end.

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question