Solved

components from DLL to a main Form HELP!!!

Posted on 1997-06-02
2
167 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now