本菜鸟想问一个怎么定义公用函数的问题!请各位大虾不吝赐教!不胜感激。 我想问一下,假如我在一个窗体中定义了一个函数,怎么声明它,才能在另外一个窗体上去调用它,而不用在调用它的窗体中再重新定义一遍。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 unit1.....function GetNodeAt(X, Y: Integer): TTreeNode;...unit2 ....uses unit1...Treenode:=unit1.GetNodeAT(x,y);... 把函数定义在implementation之前,如unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;type TForm1 = class(TForm) private { Private declarations } public { Public declarations } end;var Form1: TForm1;function func: string;implementation{$R *.dfm}function func: string;begin Result := 'Hello'end;end.在另一个单元中uses Unit1;ShowMessage(func); 放在public里,也可放在published里,不过后一种一般都是用于控件的属性和事件定义! 小问题(100分) delphi指针问题 下面的这个COM对象是怎么建立的? 在线等请教各位大虾DBXPRESS问题 求救,高分酬谢 如何对中文姓名按汉语拼音排序。给出线索就有分呀。 在midas中怎样实现容错????? 如何在ListView控件中绘底图? 环境delphi5,windows2000,sql7,fastreport,ado,记录条数怎样统计! 誰能提供一個帶源碼的屏保網址? 简单问题 想改做共享软件,大家给个建议-
.....
function GetNodeAt(X, Y: Integer): TTreeNode;
...unit2
....
uses unit1
...
Treenode:=unit1.GetNodeAT(x,y);
...
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;function func: string;implementation{$R *.dfm}function func: string;
begin
Result := 'Hello'
end;end.在另一个单元中
uses Unit1;ShowMessage(func);