unit Unit1;interfaceuses 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);beginwith 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;
这是错误:
[DCC Error] Unit1.pas(90): E2009 Incompatible types: 'Parameter Lists differ'
addnewtab()工作正常.我不明白为什么closetab()不起作用.谢谢.
解决方法 它不起作用,因为事件是使用与TNotifyEvent不同的类型声明的,并且您的方法参数必须与使用的类型(参数的数量和类型)中声明的内容匹配.导航到事件声明,您会发现:
TrkAeroTabs = class(TCustomControl) .. published .. property OnCloseTab: TOnTabCloseEvent read FOnCloseTab write FOnCloseTab;
然后,导航到TOnTabCloseEvent声明,您会发现:
TOnTabCloseEvent = procedure(Sender: TObject; Index: Integer; var Close: Boolean) of object;
所以,你必须像这样声明你的方法:
TForm1 = class(TForm) .. procedure closetab (Sender: TObject; Index: Integer; var CanClose: Boolean);procedure TForm1.closetab (Sender: TObject; Index: Integer; var CanClose: Boolean);var smarttabs: TrkAeroTabs;begin smarttabs := Sender as TrkAeroTabs; smarttabs.DeleteTab(smarttabs.ActiveTab);end;
现在,您可以成功将此方法分配给事件.
总结以上是内存溢出为你收集整理的delphi – SmartTabs运行时事件错误全部内容,希望文章能够帮你解决delphi – SmartTabs运行时事件错误所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)