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

Delphi/CppBuilder

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Main.h"
  5. #include "About.h"
  6. //---------------------------------------------------------------------------
  7. #pragma resource "*.dfm"
  8. TMainForm *MainForm;
  9. //---------------------------------------------------------------------------
  10. __fastcall TMainForm::TMainForm(TComponent *Owner)
  11. : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TMainForm::CreateMDIChild(String Name)
  16. {
  17. TMDIChild *Child;
  18. //--- create a new MDI child window ----
  19. Child = new TMDIChild(Application);
  20. Child->Caption = Name;
  21. if (FileExists (Name))
  22. Child->Memo1->Lines->LoadFromFile(Name);
  23. }
  24. //---------------------------------------------------------------------------
  25. void __fastcall TMainForm::FileNew1Execute(TObject *Sender)
  26. {
  27. CreateMDIChild("NONAME" + IntToStr(MDIChildCount + 1));
  28. }
  29. //---------------------------------------------------------------------------
  30. void __fastcall TMainForm::FileOpen1Execute(TObject *Sender)
  31. {
  32. if (OpenDialog->Execute())
  33. CreateMDIChild(OpenDialog->FileName);
  34. }
  35. //---------------------------------------------------------------------------
  36. void __fastcall TMainForm::HelpAbout1Execute(TObject *Sender)
  37. {
  38. AboutBox->ShowModal();
  39. }
  40. //---------------------------------------------------------------------------
  41. void __fastcall TMainForm::FileExit1Execute(TObject *Sender)
  42. {
  43. Close();
  44. }
  45. //---------------------------------------------------------------------------
  46. void __fastcall TMainForm::FormCreate(TObject *Sender)
  47. {
  48. OpenDialog->Title="请选择一个文本文件:";
  49. //设置对话框标题
  50. OpenDialog->InitialDir="c:pwin98";
  51. //设置对话框缺省标题
  52. OpenDialog->Filter="All files(*.*)|*.*|Text files(*.txt)|*.txt";
  53. //设置文件过滤器
  54. }
  55. //---------------------------------------------------------------------------