Page.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:3k
源码类别:

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "math.h"
  5. #include "Page.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma resource "*.dfm"
  9. TForm1 *Form1;
  10. //---------------------------------------------------------------------------
  11. __fastcall TForm1::TForm1(TComponent* Owner)
  12.         : TForm(Owner)
  13. {
  14. }
  15. //---------------------------------------------------------------------------
  16. void __fastcall TForm1::Image1Click(TObject *Sender)
  17. {
  18. float x1;
  19. float y1;
  20. float x2;
  21. float y2;
  22. float n;
  23. //定义变量
  24. x1=0;
  25. y1=(Form1->Image1->Left+Form1->Image1->Width)/4;
  26. x2=x1;
  27. y2=y1;
  28. Form1->Image1->Canvas->MoveTo((x2),(y2));
  29. //定义绘图起始点
  30. n=0;
  31. while (n<3.1415926*6)
  32.       {
  33.       x2=x2+3.1415926/12;
  34.       y2=y1-40*sin(n);
  35.       Form1->Image1->Canvas->LineTo((x2),(y2));
  36.       //绘制正弦曲线
  37.       n=n+3.1415926/180;
  38.       }
  39. }
  40. //---------------------------------------------------------------------------
  41. void __fastcall TForm1::Image2Click(TObject *Sender)
  42. {
  43. float x1;
  44. float y1;
  45. float x2;
  46. float y2;
  47. float n;
  48. //定义变量
  49. x1=0;
  50. y1=(Form1->Image2->Left+Form1->Image2->Width)/4;
  51. x2=x1;
  52. y2=y1;
  53. Form1->Image2->Canvas->MoveTo((x2),(y2));
  54. //定义绘图起始点
  55. n=0;
  56. while (n<3.1415926*6)
  57.       {
  58.       x2=x2+3.1415926/12;
  59.       y2=y1-40*cos(n);
  60.       Form1->Image2->Canvas->LineTo((x2),(y2));
  61.       //绘制正弦曲线
  62.       n=n+3.1415926/180;
  63.       }
  64. }
  65. //---------------------------------------------------------------------------
  66. void __fastcall TForm1::Image3Click(TObject *Sender)
  67. {
  68. float x1;
  69. float y1;
  70. float x2;
  71. float y2;
  72. float n;
  73. //定义变量
  74. x1=0;
  75. y1=(Form1->Image3->Left+Form1->Image3->Width)/4;
  76. x2=x1;
  77. y2=y1;
  78. Form1->Image3->Canvas->MoveTo((x2),(y2));
  79. //定义绘图起始点
  80. n=0;
  81. while (n<3.1415926*2)
  82.       {
  83.       x2=x2+3.1415926/3;
  84.       if (abs(cos(n))<0.000001)
  85.          {
  86.           y2=y1-30*sin(n)/cos(n);
  87.           Form1->Image3->Canvas->LineTo((x2),(y2));
  88.           //绘制正切曲线
  89.          }
  90.        n=n+3.1415926/180;
  91.        }
  92. }
  93. //---------------------------------------------------------------------------
  94. void __fastcall TForm1::Image4Click(TObject *Sender)
  95. {
  96. float x1;
  97. float y1;
  98. float x2;
  99. float y2;
  100. float n;
  101. //定义变量
  102. x1=0;
  103. y1=(Form1->Image4->Left+Form1->Image4->Width)/4;
  104. x2=x1;
  105. y2=y1;
  106. Form1->Image4->Canvas->MoveTo((x2),(y2));
  107. //绘图起始点
  108. n=3.1415926;
  109. while (n<3.1415926*3)
  110.       {
  111.       x2=x2+3.1415926/3;
  112.       if (abs(sin(n))<0.00001)
  113.          {
  114.          y2=y1-30*cos(n)/sin(n);
  115.          Form1->Image4->Canvas->LineTo((x2),(y2));
  116.          //绘制余切曲线
  117.          }
  118.       n=n+3.1415926/180;
  119.       }
  120. }
  121. //---------------------------------------------------------------------------
  122. void __fastcall TForm1::FormCreate(TObject *Sender)
  123. {
  124. Form1->Image1->Canvas->Pen->Width=5;
  125. Form1->Image2->Canvas->Pen->Width=5;
  126. Form1->Image3->Canvas->Pen->Width=5;
  127. Form1->Image4->Canvas->Pen->Width=5;
  128. //设置画笔大小
  129. Form1->Image1->Transparent=true;
  130. Form1->Image2->Transparent=true;
  131. Form1->Image3->Transparent=true;
  132. Form1->Image4->Transparent=true;
  133. //设置四个控件具有透明色
  134. ShowMessage("在多页控件中央单击鼠标左键显示图形!");
  135. }
  136. //---------------------------------------------------------------------------