Page.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:3k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "math.h"
- #include "Page.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Image1Click(TObject *Sender)
- {
- float x1;
- float y1;
- float x2;
- float y2;
- float n;
- //定义变量
- x1=0;
- y1=(Form1->Image1->Left+Form1->Image1->Width)/4;
- x2=x1;
- y2=y1;
- Form1->Image1->Canvas->MoveTo((x2),(y2));
- //定义绘图起始点
- n=0;
- while (n<3.1415926*6)
- {
- x2=x2+3.1415926/12;
- y2=y1-40*sin(n);
- Form1->Image1->Canvas->LineTo((x2),(y2));
- //绘制正弦曲线
- n=n+3.1415926/180;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Image2Click(TObject *Sender)
- {
- float x1;
- float y1;
- float x2;
- float y2;
- float n;
- //定义变量
- x1=0;
- y1=(Form1->Image2->Left+Form1->Image2->Width)/4;
- x2=x1;
- y2=y1;
- Form1->Image2->Canvas->MoveTo((x2),(y2));
- //定义绘图起始点
- n=0;
- while (n<3.1415926*6)
- {
- x2=x2+3.1415926/12;
- y2=y1-40*cos(n);
- Form1->Image2->Canvas->LineTo((x2),(y2));
- //绘制正弦曲线
- n=n+3.1415926/180;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Image3Click(TObject *Sender)
- {
- float x1;
- float y1;
- float x2;
- float y2;
- float n;
- //定义变量
- x1=0;
- y1=(Form1->Image3->Left+Form1->Image3->Width)/4;
- x2=x1;
- y2=y1;
- Form1->Image3->Canvas->MoveTo((x2),(y2));
- //定义绘图起始点
- n=0;
- while (n<3.1415926*2)
- {
- x2=x2+3.1415926/3;
- if (abs(cos(n))<0.000001)
- {
- y2=y1-30*sin(n)/cos(n);
- Form1->Image3->Canvas->LineTo((x2),(y2));
- //绘制正切曲线
- }
- n=n+3.1415926/180;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::Image4Click(TObject *Sender)
- {
- float x1;
- float y1;
- float x2;
- float y2;
- float n;
- //定义变量
- x1=0;
- y1=(Form1->Image4->Left+Form1->Image4->Width)/4;
- x2=x1;
- y2=y1;
- Form1->Image4->Canvas->MoveTo((x2),(y2));
- //绘图起始点
- n=3.1415926;
- while (n<3.1415926*3)
- {
- x2=x2+3.1415926/3;
- if (abs(sin(n))<0.00001)
- {
- y2=y1-30*cos(n)/sin(n);
- Form1->Image4->Canvas->LineTo((x2),(y2));
- //绘制余切曲线
- }
- n=n+3.1415926/180;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- Form1->Image1->Canvas->Pen->Width=5;
- Form1->Image2->Canvas->Pen->Width=5;
- Form1->Image3->Canvas->Pen->Width=5;
- Form1->Image4->Canvas->Pen->Width=5;
- //设置画笔大小
- Form1->Image1->Transparent=true;
- Form1->Image2->Transparent=true;
- Form1->Image3->Transparent=true;
- Form1->Image4->Transparent=true;
- //设置四个控件具有透明色
- ShowMessage("在多页控件中央单击鼠标左键显示图形!");
- }
- //---------------------------------------------------------------------------