Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

BPL + unit + component

Posted on 2003-02-27
4
Medium Priority
?
736 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
  • 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

Independent Software Vendors: 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

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…
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…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month12 days, 10 hours left to enroll

578 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