www.pudn.com > C++ Builder 6 编程实例教程.zip > List.cpp, change:2002-04-14,size:1476b


//--------------------------------------------------------------------------- 
#include <vcl.h> 
#pragma hdrstop 
 
#include "List.h" 
//--------------------------------------------------------------------------- 
#pragma package(smart_init) 
#pragma resource "*.dfm" 
TForm1 *Form1; 
//--------------------------------------------------------------------------- 
__fastcall TForm1::TForm1(TComponent* Owner) 
        : TForm(Owner) 
{ 
} 
//--------------------------------------------------------------------------- 
 
void __fastcall TForm1::FormCreate(TObject *Sender) 
{ 
 Form1->ComboBox1->Items=Screen->Fonts; 
 Form1->ListBox1->Items=Screen->Fonts; 
 //设置列表框控件的列表项 
 Form1->Memo1->Lines->LoadFromFile("如果你是我的传说.txt"); 
 //设置文本框显示内容 
} 
//--------------------------------------------------------------------------- 
 
void __fastcall TForm1::ListBox1Click(TObject *Sender) 
{ 
  Memo1->Font->Name=ListBox1->Items->Strings[ListBox1->ItemIndex]; 
  //为Memo控件应用选中的字体 
  ComboBox1->ItemIndex=ListBox1->ItemIndex; 
  //显示相应的关联选项 
} 
//--------------------------------------------------------------------------- 
 
void __fastcall TForm1::ComboBox1Click(TObject *Sender) 
{ 
  ListBox1->ItemIndex=ComboBox1->ItemIndex; 
  //显示相应的关联选项 
  Memo1->Font->Name=ListBox1->Items->Strings[ListBox1->ItemIndex]; 
  //为Memo控件应用选中的字体 
} 
//---------------------------------------------------------------------------