DLL FORMS
Delphi
About
oops
Error Handle
DLL
DllForms
Sql Commands
XML
XML Extension
API
MessageBox API DELPHI
Memory Leakage
I|O ERROR
Guest Book
Malai
DLL WIZARD
Start Borland Delphi if you didn't yet. From the Standard toolbar, click the New button .
.From the New Items dialog box, click DLL Wizard
1. Click OK.
2. To save the current project, on the main menu, click File -> Save All
3. To make things easier, from the Save Unit1 As dialog box, locate the common folder called Programs and display the Delphi folder it in the Save In combo box.
4. Click the Create New Folder button, type DLLExercise and press Enter.
5. Double-click the new folder to display it in the Save In combo box. In the File Name edit box, change the name of the project to DLLProject and click Save.
6. Examine and read the whole file, especially the commented section.
7. Change the content of the file as follows:
DLL WIZARD
.
DLL FORMS
Now we will create a project to use our DLL.
1. Start a new application with the default form.
2. To save the project, on the main menu, click File -> Save All.
3. Locate and display the same folder in which the DLL project was created.
4. Save the unit as Main and the project as ParaRect
5. Design the form as follows:
6. Besides the labels you can read, from top -> down, the form has five Edit controls named edtLength, edtHeight, edtWidth, edtArea, and edtVolume respectively. Then add two buttons named btnCalculate and btnExit. 7. On the form, double-click the Exit button 8. On the form, double-click the Calculate button. 9. Return to the form and double-click the Calculate button. To call the DLL, change the file as follows:
it Main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
edtLength: TEdit;
edtHeight: TEdit;
edtWidth: TEdit;
edtArea: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
btnVolume: TLabel;
edtVolume: TEdit;
btnCalculate: TButton;
Shape1: TShape;
btnExit: TButton;
procedure btnExitClick(Sender: TObject);
procedure btnCalculateClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
procedure BoxProperties(L, H, W : Double; var A, V : Double); external 'DLLProject.dll';
implementation
{$R *.DFM}
procedure TForm1.btnExitClick(Sender: TObject);
begin
Close;
end;
procedure TForm1.btnCalculateClick(Sender: TObject);
var
Length, Height, Width, Area, Volume : Double;
begin
Length := StrToFloat(edtLength.Text);
Height := StrToFloat(edtHeight.Text);
Width := StrToFloat(edtWidth.Text);
BoxProperties(Length, Height, Width, Area, Volume);
edtArea.Text := FloatToStr(Area);
edtVolume.Text := FloatToStr(Volume);
end;
end.