Solved

Calling function from Bpl

Posted on 2006-06-12
9
489 Views
Last Modified: 2010-04-05
This is my Bpl:

unit GlobalUnit;


interface
uses ExtCtrls, Buttons;
//procedure vcPanelResize(Sender: TObject);

implementation

procedure vcPanelResize(Panel:TPanel);
var
  i,m,n:integer;
begin
  m:=1; n:=1;
  for i:=0 to Panel.ControlCount-1 do
    begin
      if Panel.Controls[i].ClassType=TBitBtn then
        begin
          with Panel.Controls[i] as TBitBtn do
            begin
              Top:=m;
              Left:=n;
              Width:=Panel.Width-2;
              m:=m+Height+1;
            end;
        end;
    end;
end;

exports
vcPanelResize name 'vcPanelResize';

end.

How can I call procedure vcPanelResize from my main program.
0
Comment
Question by:cula99
  • 5
  • 4
9 Comments
 
LVL 28

Expert Comment

by:ciuly
ID: 16885339
something like this:
uses GlobalUnit;

....
vcPanelResize(apanel);
make sure that the bpl is in the path of the program (can be current dir). for compiling, make sure tha bpl is in the lib path of the project
0
 
LVL 2

Author Comment

by:cula99
ID: 16885429
I can put it in my uses cloasu, but I cant call procedure later. I supouse, I didnt declare it well in bpl.

Cula
0
 
LVL 28

Expert Comment

by:ciuly
ID: 16885449
I never wrote a bpl :D (I know, some ppl might remain ... "amazed" (can't find the right word))
I'll do that in a few minutes and let you know my findings
0
 
LVL 2

Author Comment

by:cula99
ID: 16885463
10x:))
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 28

Accepted Solution

by:
ciuly earned 125 total points
ID: 16886124
I found this article: http://delphi.about.com/od/objectpascalide/l/aa010901c.htm
following it, I created a test app and run it just fine.

what I have done is:
unit Unit1;

interface

procedure test;

implementation

uses dialogs;

procedure test();
begin
  showmessage('test');
end;

exports
  test name 'test';

end.

in package1. changed in project p[roperties to output in current dir. compiled. installed. then created a test app:

unit bla;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses unit1;

procedure TForm1.FormCreate(Sender: TObject);
begin
  test;
end;

end.

open project settings, go to packages, check build with runtime packages and add "package1".
compile.
copied bpl file to the exe dir and run exe. message was shown.

in your case: uncomment:
interface
uses ExtCtrls, Buttons;
//procedure vcPanelResize(Sender: TObject);

and make sure you followed the aboe steps.
0
 
LVL 2

Author Comment

by:cula99
ID: 16886332
Its working perfectly. 10x one more time:)))
0
 
LVL 28

Expert Comment

by:ciuly
ID: 16886373
usually, when it works perfectly, you give an A ;) just for the future :)
0
 
LVL 2

Author Comment

by:cula99
ID: 16887523
its working perfectly but not as I wont it. Now I have to ship all bpls I used in program that is why B. It works perfectly but it is not the best solution.
0
 
LVL 28

Expert Comment

by:ciuly
ID: 16888674
well ... that is what build with runtime packages mean. I thought you know. the best solution is not to use runtime packages, I don't know of any way to use partly runtime packages, partly design packages. if you want to have some code "outside" and some compiled into the exe, then you will have to use dll's. there is no other way, AFAIK.
peace
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

11 Experts available now in Live!

Get 1:1 Help Now