C
cowbird
Unregistered / Unconfirmed
GUEST, unregistred user!
自己写了个菜单事件MenuItemClick,然后做成了DLL,使用的时候结果报错,求教!
情况一: 不使用dll的时候,正常。
procedure TForm1.MenuItemClick(Sender:TObject);
begin
if TMenuItem(Sender).Name = 'MenuItemOne' then
showmessage('one');
if TMenuItem(Sender).Name = 'MenuItemtwo' then
showmessage('two');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MenuItmeone.OnClick:=MenuItemClick;
MenuItemTwnclick:=MenuItemClick;
end;
情况二,使用DLL,报错
library Project2;
uses
SysUtils,
Menus,
QDialogs,
Classes;
{$R *.res}
procedure MenuItemClick(Sender:TObject);
begin
if TMenuItem(Sender).Name = 'MenuItemone' then
showmessage('one');
if TMenuItem(Sender).Name = 'MenuItemtwo' then
showmessage('two');
end;
exports
MenuItemClick;
begin
end.
//-----------------------------------------
主窗口调用:
procedure MenuItemClick(Sender:TObject);far external 'project2.dll';
procedure TForm1.FormCreate(Sender: TObject);
begin
MenuItmeone.OnClick:=MenuItemClick;
MenuItemTwnclick:=MenuItemClick;
end;
报错信息:
[Error] Unit1.pas(47): Incompatible types: 'method pointer and regular procedure'
情况一: 不使用dll的时候,正常。
procedure TForm1.MenuItemClick(Sender:TObject);
begin
if TMenuItem(Sender).Name = 'MenuItemOne' then
showmessage('one');
if TMenuItem(Sender).Name = 'MenuItemtwo' then
showmessage('two');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MenuItmeone.OnClick:=MenuItemClick;
MenuItemTwnclick:=MenuItemClick;
end;
情况二,使用DLL,报错
library Project2;
uses
SysUtils,
Menus,
QDialogs,
Classes;
{$R *.res}
procedure MenuItemClick(Sender:TObject);
begin
if TMenuItem(Sender).Name = 'MenuItemone' then
showmessage('one');
if TMenuItem(Sender).Name = 'MenuItemtwo' then
showmessage('two');
end;
exports
MenuItemClick;
begin
end.
//-----------------------------------------
主窗口调用:
procedure MenuItemClick(Sender:TObject);far external 'project2.dll';
procedure TForm1.FormCreate(Sender: TObject);
begin
MenuItmeone.OnClick:=MenuItemClick;
MenuItemTwnclick:=MenuItemClick;
end;
报错信息:
[Error] Unit1.pas(47): Incompatible types: 'method pointer and regular procedure'