13,825
社区成员
发帖
与我相关
我的任务
分享
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int x, y;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormActivate(TObject *Sender)
{
WindowState = wsMaximized;
Timer1->Interval = 50;
Randomize();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
x = random(Screen->Width-10);
y = random(Screen->Height-10);
Canvas->Pen->Color = (Graphics::TColor)random(865535);
switch (random(5))
{
case0: Canvas->Pen->Style = psSolid; break;
case1: Canvas->Pen->Style = psDash; break;
case2: Canvas->Pen->Style = psDot; break;
case3: Canvas->Pen->Style = psDashDot; break;
case4: Canvas->Pen->Style = psDashDotDot; break;
}
Canvas->Rectangle(x, y, x + random(400), y + random(400));
}