ChildWin.cpp
上传用户:lulishicai
上传日期:2010-03-01
资源大小:13202k
文件大小:2k
源码类别:
Delphi/CppBuilder
开发平台:
C++ Builder
- //---------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "ChildWin.h"
- //---------------------------------------------------------------------
- #pragma resource "*.dfm"
- //---------------------------------------------------------------------
- __fastcall TMDIChild::TMDIChild(TComponent *Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------
- void __fastcall TMDIChild::FormClose(TObject *Sender, TCloseAction &Action)
- {
- if(Memo1->Modified)
- //如果文档被修改
- if(SaveDialog1->Execute())
- //显示对话框
- Memo1->Lines->SaveToFile(SaveDialog1->FileName);
- //存储文件
- Action = caFree;
- //关闭窗口
- }
- //---------------------------------------------------------------------
- void __fastcall TMDIChild::Close1Click(TObject *Sender)
- {
- Application->MainForm->ActiveMDIChild->Close();
- //关闭当前活动的窗口
- }
- //---------------------------------------------------------------------------
- void __fastcall TMDIChild::Save1Click(TObject *Sender)
- {
- if(SaveDialog1->Execute())
- Memo1->Lines->SaveToFile(SaveDialog1->FileName);
- }
- //---------------------------------------------------------------------------
- void __fastcall TMDIChild::FormCreate(TObject *Sender)
- {
- SaveDialog1->Title="请选择一个文本文件:";
- //设置对话框标题
- SaveDialog1->InitialDir="c:pwin98";
- //设置对话框缺省目录
- SaveDialog1->Filter="All files(*.*)|*.*|Text files(*.txt)|*.txt";
- //设置文件过滤器
- }
- //---------------------------------------------------------------------------