Main.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:2k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "Main.h"
- #include "About.h"
- //---------------------------------------------------------------------------
- #pragma resource "*.dfm"
- TMainForm *MainForm;
- //---------------------------------------------------------------------------
- __fastcall TMainForm::TMainForm(TComponent *Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::CreateMDIChild(String Name)
- {
- TMDIChild *Child;
- //--- create a new MDI child window ----
- Child = new TMDIChild(Application);
- Child->Caption = Name;
- if (FileExists (Name))
- Child->Memo1->Lines->LoadFromFile(Name);
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::FileNew1Execute(TObject *Sender)
- {
- CreateMDIChild("NONAME" + IntToStr(MDIChildCount + 1));
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::FileOpen1Execute(TObject *Sender)
- {
- if (OpenDialog->Execute())
- CreateMDIChild(OpenDialog->FileName);
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::HelpAbout1Execute(TObject *Sender)
- {
- AboutBox->ShowModal();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::FileExit1Execute(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::FormCreate(TObject *Sender)
- {
- OpenDialog->Title="请选择一个文本文件:";
- //设置对话框标题
- OpenDialog->InitialDir="c:pwin98";
- //设置对话框缺省标题
- OpenDialog->Filter="All files(*.*)|*.*|Text files(*.txt)|*.txt";
- //设置文件过滤器
- }
- //---------------------------------------------------------------------------