Я создал DLL в Delphi 10.3.3 и скомпилировал ее (как 32-разрядную):
library TestDLL;
uses
Vcl.ExtCtrls,
Vcl.Graphics,
System.SysUtils,
System.Classes;
{$R *.res}
procedure ColorPanel(APanel: TPanel);
begin
APanel.Color := clRed;
end;
exports
ColorPanel;
begin
end.
Затем в Delphi 10.3.3 я создал приложение VCL для размещения DLL:
unit Main;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;
type
TForm3 = class(TForm)
pnlTest: TPanel;
btnTest: TButton;
procedure btnTestClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure ColorPanel(APanel: TPanel); external 'TestDLL.dll';
procedure TForm3.btnTestClick(Sender: TObject);
begin
ColorPanel(pnlTest);
end;
end.
Это файл формы 'Main.dfm':
object Form3: TForm3
Left = 0
Top = 0
Caption = 'Form3'
ClientHeight = 217
ClientWidth = 359
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
PixelsPerInch = 120
TextHeight = 16
object pnlTest: TPanel
Left = 0
Top = 0
Width = 153
Height = 217
Align = alLeft
Caption = 'pnlTest'
TabOrder = 0
end
object btnTest: TButton
Left = 208
Top = 24
Width = 75
Height = 25
Caption = 'Test'
TabOrder = 1
OnClick = btnTestClick
end
end
И это файл проекта 'TestDLL.dpr':
program DllHost;
uses
Vcl.Forms,
Main in 'Main.pas' {Form3};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm3, Form3);
Application.Run;
end.
Нажатие на кнопку должно раскрасить панель в красный цвет.
Почему она не работает и как я могу заставить ее работать?