本菜鸟想问一个怎么定义公用函数的问题!请各位大虾不吝赐教!不胜感激。 我想问一下,假如我在一个窗体中定义了一个函数,怎么声明它,才能在另外一个窗体上去调用它,而不用在调用它的窗体中再重新定义一遍。 解决方案 » 免费领取超大流量手机卡,每月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里,不过后一种一般都是用于控件的属性和事件定义! 就百合的要求,看HT的悲惨,散分.... 将一个磁盘映像文件虚拟成一个磁盘要怎么做??? 基于access数据库的时间日期查询难题,各位帮我想想,实在不行了,努力了好几天,顶者有分! Dll调用后释放的问题 用delphi如何向word模板的指定位置贴入图像~~~~困扰一个星期的问题~` 简单问题,大哥大姐请帮忙,怎么把2得10次方得结果1024保存到一个整型变量i里面??? 改变Image.Picture.Assign时,是否会造成资源泄漏?? 怎样抓取当前鼠标形状: dbx 连接 mssql05 老是出错 如何定义能够长时间保存值的变量? 简单问题 想改做共享软件,大家给个建议-
.....
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);