Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

components from DLL to a main Form HELP!!!

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
Charlie V
Asked:
Charlie V
1 Solution
 
ozzyCommented:
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
 
Charlie VAuthor Commented:
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now