如何是有delphi创建一个pen的全局对象,实现在当前单元内所有的类、方法都可以用它画出想画的东西!谢谢…
1个回答
展开全部
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
MyClass = Class
private
FPen : TPen;
function GetPen: TPen;
public
property ClassPen : TPen read GetPen;
end;
implementation
{ MyClass }
var
myPen : TPen;
function MyClass.GetPen: TPen;
begin
FPen := myPen;
end;
initialization
myPen:= TPen.Create ;
finalization
myPen.Free ;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
MyClass = Class
private
FPen : TPen;
function GetPen: TPen;
public
property ClassPen : TPen read GetPen;
end;
implementation
{ MyClass }
var
myPen : TPen;
function MyClass.GetPen: TPen;
begin
FPen := myPen;
end;
initialization
myPen:= TPen.Create ;
finalization
myPen.Free ;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询