用画笔作图

mazhichao84 2010-08-01 03:08:35
请哪位高手指点一下
代码:
//---------------------------------------------------------------------------

#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
...全文
97 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mazhichao84 2010-08-01
  • 打赏
  • 举报
回复
有几点不懂,问一下妖哥
Randomize();
x = random(Screen->Width-10);
y = random(Screen->Height-10);
Canvas->Pen->Color = (Graphics::TColor)random(865535);

Canvas->Rectangle(x, y, x + random(400), y + random(400));
请帮我解释一下
谢谢!!
mazhichao84 2010-08-01
  • 打赏
  • 举报
回复
多谢指教
呵呵...
ccrun.com 2010-08-01
  • 打赏
  • 举报
回复
#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));
}

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧