代码:
//---------------------------------------------------------------------------
#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=Randcmize(Screen->Width-10);
y=Randcmize(Screen->Height-10);
Canvas->Pen->Color=(Graphics::TColor)Randomize(865535);
switch(Randomize(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+Randomize(400),y+Randomize(400));
}
//---------------------------------------------------------------------------
错误提示:
Build
[C++ Error] Unit1.cpp(29): E2268 Call to undefined function 'Randcmize'
[C++ Error] Unit1.cpp(31): E2227 Extra parameter in call to _fastcall Randomize()
[C++ Error] Unit1.cpp(31): E2468 Value of type void is not allowed
[C++ Error] Unit1.cpp(32): E2227 Extra parameter in call to _fastcall Randomize()
[C++ Error] Unit1.cpp(32): E2383 Switch selection expression must be of integral type
[C++ Error] Unit1.cpp(40): E2227 Extra parameter in call to _fastcall Randomize()
[C++ Error] Unit1.cpp(40): E2109 Not an allowed type
[C++ Error] Unit1.cpp(40): E2227 Extra parameter in call to _fastcall Randomize()
[C++ Error] Unit1.cpp(40): E2109 Not an allowed type