我些的控件出现了慕名奇妙的问题?请大侠们帮忙。。。(50分)

  • 主题发起人 主题发起人 Neco
  • 开始时间 开始时间
N

Neco

Unregistered / Unconfirmed
GUEST, unregistred user!
unit TimeLabel;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
StdCtrls,ExtCtrls;

type
TTimeLabel = class(TCustomLabel)
private
obj_Timer:TTimer;
function GetActive:boolean ;
procedure SetActive (value:boolean);
protected
procedure UpdateClock(Sender: TObject);
public
{ Public declarations }
Constructor create(AOwner:Tcomponent);override;

published
property Align;
property Alignment;
property Color;
property Font;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Transparent;
property Visible;
property active :boolean read getactive write setactive; //default true;
end;

procedure Register;

implementation

Constructor TTimeLabel.create(AOwner:Tcomponent);
begin
inherited create(aowner);
// Create the internal timer object .
obj_timer:=TTimer.create(self);
obj_timer.OnTimer :=UpdateClock;
obj_timer.Enabled :=false;
end;
procedure TTimeLabel.UpdateClock(Sender: TObject);
begin
// Set the current time as caption .
caption:=FormatDateTime('dddd, mmmm d, yyyy,hh:mm AM/PM',date);
//caption:=timetostr(time);
end;


function TTimeLabel.GetActive():boolean ;
begin
result:=active;
end;

procedure TTimeLabel.SetActive (value:boolean);
begin
obj_timer.Enabled :=value;
end;

procedure Register;
begin
RegisterComponents('Standard', [TTimeLabel]);
end;

end.
///是个时间显示控件,可我安装到delphi5。0使用时报错“Stack overflow"
 
datoncg , Can you tell me why ????
 
改好了, 你先到死循环里了. [:(]

unit TimeLabel;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls,
StdCtrls,ExtCtrls;

type
TTimeLabel = class(TCustomLabel)
private
FActive : Boolean;
obj_Timer:TTimer;
function GetActive:boolean ;
procedure SetActive (value:boolean);
protected
procedure UpdateClock(Sender: TObject);
public
{ Public declarations }
constructor Create(AOwner:Tcomponent);override;
destructor Destroy; override;
published
property Align;
property Alignment;
property Color;
property Font;
property ParentColor;
property ParentFont;
property ParentShowHint;
property PopupMenu;
property ShowHint;
property Transparent;
property Visible;
property Active :boolean read GetActive write SetActive; //default true;
end;

procedure Register;

implementation

constructor TTimeLabel.create(AOwner:Tcomponent);
begin
inherited Create(aOwner);
// Create the internal timer object .
obj_timer:=TTimer.Create(Self);
obj_timer.OnTimer :=UpdateClock;
obj_timer.Enabled :=false;
end;

destructor TTimeLabel.Destroy;
begin
if Assigned(Obj_Timer) then FreeAndNil(Obj_Timer);
inherited Destroy;
end;

procedure TTimeLabel.UpdateClock(Sender: TObject);
begin
// Set the current time as caption .
caption:=FormatDateTime('dddd, mmmm d, yyyy,hh:mm AM/PM',date);
//caption:=timetostr(time);
end;


function TTimeLabel.GetActive():boolean ;
begin
result:=FActive;
end;

procedure TTimeLabel.SetActive (value:boolean);
begin
obj_timer.Enabled :=value;
FActive := Obj_Timer.Enabled;
end;

procedure Register;
begin
RegisterComponents('Standard', [TTimeLabel]);
end;

end.
 
多人接受答案了。
 
后退
顶部