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

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <stdlib.h>
  5. #include "Color.h"
  6. //---------------------------------------------------------------------------
  7. #pragma package(smart_init)
  8. #pragma link "CGRID"
  9. #pragma resource "*.dfm"
  10. TForm1 *Form1;
  11. //---------------------------------------------------------------------------
  12. __fastcall TForm1::TForm1(TComponent* Owner)
  13.         : TForm(Owner)
  14. {
  15. }
  16. //---------------------------------------------------------------------------
  17. void __fastcall TForm1::Button1Click(TObject *Sender)
  18. {
  19.    Form1->Memo1->Font->Color=RGB(random(255),random(255),random(255));
  20.    //在Memo控件中以随机前景色显示文本
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TForm1::Button2Click(TObject *Sender)
  24. {
  25.    Form1->Memo1->Color=RGB(random(255),random(255),random(255));
  26.    //在Memo控件中显示随机背景色
  27. }
  28. //---------------------------------------------------------------------------
  29. void __fastcall TForm1::CColorGrid1Change(TObject *Sender)
  30. {
  31. Form1->Memo1->Font->Color=Form1->CColorGrid1->ForegroundColor;
  32. Form1->Memo1->Color=Form1->CColorGrid1->BackgroundColor;
  33. //随时更改文本框的颜色设置
  34. }
  35. //---------------------------------------------------------------------------
  36.