?
Solved

BPL + unit + component

Posted on 2003-02-27
4
Medium Priority
?
719 Views
Last Modified: 2013-11-18
Hi,

I create a .BPL.
To this .BPL, I add a TForm to the package.
At this TForm, I add a TPersoLabel.

I need to load dynamically the TForm from Package. I code:

procedure APropos(H: TComponent);
var
  Plugin: HModule;
  Cls: TPersistentClass;
begin
  Plugin := LoadPackage('AlphoPackD6.bpl');
  if Plugin <> 0 then
  begin
    Cls := GetClass('TfenAPropos');
    if Cls <> nil then
    begin
      with TComponentClass(Cls).Create(H) as TCustomForm do
      begin
        ShowModal;
        Free;
      end;
    end
    else
      ShowMessage('TFenAPropos not found in AlphoPackD6');
    UnloadPackage(Plugin);
  end
  else
    ShowMessage('AlphoPackD6 not found');
end;

Before ShowModal, I want to modify PersoLabel1.caption.

How can I do that, because TCustomForm doesn't know TPersoLabel ?

Jean-Luc !
0
Comment
Question by:Alphomega
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
mocarts earned 600 total points
ID: 8033346
I assume you are using standard runtime packages (for exe and for your plugin bpl's)
you can use FindComponent(name: string) of form;

var
  cmp : TComponent;
..
begin
...
with TComponentClass(Cls).Create(H) as TCustomForm do
begin
  cmp := FindComponent('PersoLabel1');
  if assigned(cmp) then
// if inherited from TCustomLabel..
//if not - you must include your unit in uses clause
// and in runtime package, because both exe and bpl uses it
    TCustomLabel(cmp).Caption := 'My caption';    ShowModal;
end;
..
end;

but if this is a plugin - why program costumizes it? plugin must costumize program..

wbr, mo.
0
 

Author Comment

by:Alphomega
ID: 8033436
Ok, that's work because caption is TCustomLabel property !

But, If I use a TPersoLabel with new property not implemented in TCustomLabel, is there a way to access this property ?
0
 
LVL 9

Expert Comment

by:mocarts
ID: 8033480
if you use runtime packages - yes - by typecasting to TPersoLabel.
as I mentioned above - if exe and dynamically loaded bpl uses same unit, it must be placed in runtime package.
0
 

Author Comment

by:Alphomega
ID: 8035018
OK, Thanks a lot !

Jean-Luc !
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 11 hours left to enroll

765 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