李
李璋琦
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大虾,小弟练习写控件,但是以下程序通过编译,单安不上。
请各位帮忙。
unit Tdate;
interface
uses windows,classes,SysUtils, stdctrls;
type
Tdaterdd=class(TButton)
private
FYear,FMonth,Fday:integer;
Fonchange:TNotifyevent;
protected
procedure setMonth(val:integer);
procedure setDay(val:integer);
proceduredo
change;virtual;
public
constructor create(aowner:Tcomponent);override;
property Onchange:TNotifyEvent read FOnchange Write Fonchange;
procedure setvalue(y,m,d:integer);
function gettext:String;
//properties:
Property Day:integer read fday write setday;
Property Month:Integer read fmonth write setmonth;
Property year:integer read fyear write Fyear;
Property Text:string read GetText;
end;
//
EdateOutofRange=class(exception);
procedure register;
implementation
procedure register;
begin
registercomponents('Win95',[Tdaterdd]);
end;
function Tdaterdd.gettext;
begin
gettext:=format('%4d-%2d-%2d',[year,month,day]);
end;
constructor Tdaterdd.create(aowner:Tcomponent);
var
Y,m,d:word;
begin
inherited create(aowner);
Decodedate(now,y,m,d);
Fyear:=y;
Fmonth:=m;
Fday:=d;
end;
procedure Tdaterdd.DoChange;
begin
If Assigned(fOnChange) then
FOnchange(self);
end;
procedure Tdaterdd.setmonth (val:integer);
begin
if (val>=1) and (Val<=12) then
begin
Fmonth:=val;
do
change;
End
else
EdateOutofRange.create('月份超出范围');
end;
Procedure Tdaterdd.setday (val:integer);
begin
if (val>=1) and (Val<=31) then
begin
Fday:=val;
do
Change;
End
else
EdateOutofRange.create('日期超出范围');
end;
procedure Tdaterdd.setvalue(y,m,d:integer);
begin
Fyear:=y;
setmonth(m);
setday(d);
end;
end.
请各位帮忙。
unit Tdate;
interface
uses windows,classes,SysUtils, stdctrls;
type
Tdaterdd=class(TButton)
private
FYear,FMonth,Fday:integer;
Fonchange:TNotifyevent;
protected
procedure setMonth(val:integer);
procedure setDay(val:integer);
proceduredo
change;virtual;
public
constructor create(aowner:Tcomponent);override;
property Onchange:TNotifyEvent read FOnchange Write Fonchange;
procedure setvalue(y,m,d:integer);
function gettext:String;
//properties:
Property Day:integer read fday write setday;
Property Month:Integer read fmonth write setmonth;
Property year:integer read fyear write Fyear;
Property Text:string read GetText;
end;
//
EdateOutofRange=class(exception);
procedure register;
implementation
procedure register;
begin
registercomponents('Win95',[Tdaterdd]);
end;
function Tdaterdd.gettext;
begin
gettext:=format('%4d-%2d-%2d',[year,month,day]);
end;
constructor Tdaterdd.create(aowner:Tcomponent);
var
Y,m,d:word;
begin
inherited create(aowner);
Decodedate(now,y,m,d);
Fyear:=y;
Fmonth:=m;
Fday:=d;
end;
procedure Tdaterdd.DoChange;
begin
If Assigned(fOnChange) then
FOnchange(self);
end;
procedure Tdaterdd.setmonth (val:integer);
begin
if (val>=1) and (Val<=12) then
begin
Fmonth:=val;
do
change;
End
else
EdateOutofRange.create('月份超出范围');
end;
Procedure Tdaterdd.setday (val:integer);
begin
if (val>=1) and (Val<=31) then
begin
Fday:=val;
do
Change;
End
else
EdateOutofRange.create('日期超出范围');
end;
procedure Tdaterdd.setvalue(y,m,d:integer);
begin
Fyear:=y;
setmonth(m);
setday(d);
end;
end.