T
tianxia
Unregistered / Unconfirmed
GUEST, unregistred user!
我在学习做一个简单的时钟时,遇到了一些麻烦,
经过是这样的:
我先是新建了个工程,
然后,按顺在上面加了,image1,shape1,lable1,timer1 把FORM属性设了一下,如下:
bordrestyle:bsnone
formstyle:fsstayontop
image1:
picture:随便弄了个。
strecth:ture;
shape1:
style:bsclear
pen.color 随便弄了个。
pen.width 6
shape:stcircle
lable1:
font.color:随意。
transparent:ture
{并移到图片上,,,}
不知为何,编译运行时总是执行成了一个就是一个光光的白色的圆啊(在屏幕的右上角。)
请高手指点一二啊,,,
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, jpeg;
type
TForm1 = class(TForm)
Image1: TImage;
Shape1: TShape;
Label1: TLabel;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Shape1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
const RC=90;
var p:array[0..359] of TPoint;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
x,y:Real;
a: Integer;
rgn:HRGN;
begin
for a:=0 to 359do
begin
x:=RC*Cos(a*PI/180)+RC;
Y:=RC-RC*Sin(a*PI/180);
p[a].x:=Trunc(x);
p[a].y:=Trunc;
end;
Rgn:=CreatePolygonRgn(p,360,WINDING);
SetWindowRgn(Handle,rgn,True);
ClientWidth:=RC+RC;
ClientHeight:=RC+RC;
Top:=10;
Left:=Screen.Width-Width-10;
ShowHint:=True;
Hint:='时钟,不懂么?'+#13+'单击你的右键结束程序...';
Shape1.Width:=RC+RC+1;
Shape1.height:=RC+RC+1;
Shape1.top:=-1;
Shape1.Left:=-1;
Image1.Width:=RC+RC Div 2;
Image1.height:=RC+RC Div 2;
Image1.Top:=RC Div 2;
Image1.Left:=RC Div 2;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
label1.Caption:=TimeToStr(Time);
end;
procedure TForm1.Shape1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if Button=mbRight then
close;
end;
end.
经过是这样的:
我先是新建了个工程,
然后,按顺在上面加了,image1,shape1,lable1,timer1 把FORM属性设了一下,如下:
bordrestyle:bsnone
formstyle:fsstayontop
image1:
picture:随便弄了个。
strecth:ture;
shape1:
style:bsclear
pen.color 随便弄了个。
pen.width 6
shape:stcircle
lable1:
font.color:随意。
transparent:ture
{并移到图片上,,,}
不知为何,编译运行时总是执行成了一个就是一个光光的白色的圆啊(在屏幕的右上角。)
请高手指点一二啊,,,
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, jpeg;
type
TForm1 = class(TForm)
Image1: TImage;
Shape1: TShape;
Label1: TLabel;
Timer1: TTimer;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Shape1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
const RC=90;
var p:array[0..359] of TPoint;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
x,y:Real;
a: Integer;
rgn:HRGN;
begin
for a:=0 to 359do
begin
x:=RC*Cos(a*PI/180)+RC;
Y:=RC-RC*Sin(a*PI/180);
p[a].x:=Trunc(x);
p[a].y:=Trunc;
end;
Rgn:=CreatePolygonRgn(p,360,WINDING);
SetWindowRgn(Handle,rgn,True);
ClientWidth:=RC+RC;
ClientHeight:=RC+RC;
Top:=10;
Left:=Screen.Width-Width-10;
ShowHint:=True;
Hint:='时钟,不懂么?'+#13+'单击你的右键结束程序...';
Shape1.Width:=RC+RC+1;
Shape1.height:=RC+RC+1;
Shape1.top:=-1;
Shape1.Left:=-1;
Image1.Width:=RC+RC Div 2;
Image1.height:=RC+RC Div 2;
Image1.Top:=RC Div 2;
Image1.Left:=RC Div 2;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
label1.Caption:=TimeToStr(Time);
end;
procedure TForm1.Shape1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if Button=mbRight then
close;
end;
end.