This is the part of code where I get the error:
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cefvcl, Vcl.ExtCtrls, Vcl.StdCtrls, ceflib,
Vcl.ComCtrls, Vcl.ImgList, Vcl.Imaging.pngimage, Vcl.Buttons, JvSpeedButton, Themes,
JvExComCtrls, JvComCtrls, JvgPage, Vcl.ToolWin, JvToolBar, Vcl.Menus,
Vcl.Mask, JvExMask, JvToolEdit, JvExButtons, JvButtons, rkSmartTabs, rkAeroTabs;
type
TForm1 = class(TForm)
{....}
procedure FormCreate(Sender: TObject);
procedure addnewtab (Sender: TObject);
procedure closetab (Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{....}
procedure TForm1.closetab (Sender: TObject);
var
smarttabs: TrkAeroTabs;
begin
smarttabs := Sender as TrkAeroTabs;
smarttabs.DeleteTab(smarttabs.ActiveTab);
end;
procedure TForm1.addnewtab (Sender: TObject);
var
smarttabs: TrkAeroTabs;
begin
smarttabs := Sender as TrkAeroTabs;
smarttabs.AddTab('New Tab');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with TrkAeroTabs.Create(self) do
begin
OnCloseTab := closetab; //***ERROR HERE***
OnAddClick := addnewtab;
Parent := Self;
Align := alClient;
AddTab('New Tab');
if ClassType = TrkAeroTabs then
begin
ColorBackground := clBlack;
with Self do
begin
GlassFrame.Top := 25;
GlassFrame.Enabled := True;
end;
end;
ShowButton := True;
AllowTabDrag := True;
end;
end;
this is the error:
[DCC Error] Unit1.pas(90): E2009 Incompatible types: 'Parameter lists differ'
addnewtab() works fine. I do not understand why closetab() does not work. Thanks.
It doesn’t work because the event is declared with a type different from TNotifyEvent, and your method parameters have to match to what is declared in the type used (number and type of parameters).
Navigate to the event declaration and you find this:
Then, navigate to the TOnTabCloseEvent declaration and you find this:
So, you have to declare your method like this:
And now, you can successfully assign this method to the event.