Main.cpp
上传用户:lhxd_sz
上传日期:2014-10-02
资源大小:38814k
文件大小:2k
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "unit1.h"
- #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::Button1Click(TObject *Sender)
- {
- TForm1 *wnd;
- wnd = new TForm1(Application);
- wnd->Caption="我的子窗口";
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Button2Click(TObject *Sender)
- {
- for(int i = 0; i < MDIChildCount; i++)
- ShowMessage(MDIChildren[i]->Caption);
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::Button3Click(TObject *Sender)
- {
- TForm1 *wnd;
- for(int i = 0; i < MDIChildCount; i++)
- MDIChildren[i]->Close();
- wnd = new TForm1(Application);
- wnd->Caption="我的子窗口";
- }
- //---------------------------------------------------------------------------