|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit3.h"
#include "math.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm3 *Form3;
//---------------------------------------------------------------------------
__fastcall TForm3::TForm3(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm3::FormPaint(TObject *Sender)
{
double x1,y1,x2,y2;
const int nscale=100;
Canvas->Pen->Color=clRed;//设置FORM界面的画笔颜色。
for (int i=0;i<720;i++)
{
double dAngle=i*M_PI/360;//M_PI在math.h里
double E=nscale*(1+sin(3*dAngle));
x1=320+E*cos(dAngle);
x2=320+E*cos(dAngle+M_PI/5);
y1=240+E*sin(dAngle);
y2=240+E*sin(dAngle+M_PI/5);
Canvas->MoveTo(x1,y1);//移到X1,Y2位置
Canvas->LineTo(x2,y2);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm3::FormCreate(TObject *Sender)
{
}
//---------------------------------------------------------------------------
如果在Form上加个TButton控件,再把FormPaint()里面的代码加到TButton中,按一下Button,就会显示
![](http://cache.amobbs.com/bbs_upload782111/files_15/ourdev_452093.JPG)
(原文件名:0.JPG)
(这是加了Button后的效果,不加的话,运行程序后是没有任何显示的,我用的是BCB 2007) |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|