设为首页 加入收藏

TOP

【转】代码编辑器(三)-PageControl和类(三)
2017-10-10 12:06:42 】 浏览:7397
Tags:代码 编辑器 -PageControl 和类
ick(Sender: TObject);
77 var 78 tab: TTabSheet; 79 TeMemo: TRecEdit; 80 begin 81 tab := TTabSheet.Create(PageControl1); 82 tab.PageControl := PageControl1; 83 TeMemo := TRecEdit.Create(tab); 84 TeMemo.Parent := tab; 85 TeMemo.fPath := ''; 86 TeMemo.Align := alClient; 87 TeMemo.ScrollBars := ssVertical; 88 C1.Enabled := True; 89 L1.Enabled := True; 90 end; 91 92 function TForm1.ClosePageQuery(pIndex: Integer): Boolean; 93 var 94 ret: Integer; 95 begin 96 if TRecEdit(PageControl1.Pages[pIndex].Controls[0]).Modified then begin 97 ret := Application.MessageBox('当前文件内容已经修改,想保存文件吗?', '保存', 51); //51=48+3 98 case ret of 99 IDYES: FileSave1.Click(); 100 IDCANCEL: begin 101 Result := False; 102 Exit; 103 end; 104 end; 105 end; 106 PageControl1.Pages[pIndex].Destroy; 107 Result := True; 108 end; 109 110 function TForm1.ClosePageQuery: Boolean; 111 begin 112 Result := ClosePageQuery(PageControl1.ActivePageIndex); 113 end; 114 115 procedure TForm1.CloseAll1Click(Sender: TObject); 116 begin 117 while PageControl1.PageCount > 0 do 118 if not ClosePageQuery() then 119 break; 120 if PageControl1.PageCount = 0 then begin 121 C1.Enabled := False; 122 L1.Enabled := False; 123 end; 124 end; 125 126 procedure TForm1.ClosePage1Click(Sender: TObject); 127 begin 128 ClosePageQuery(PageControl1.ActivePageIndex); 129 if PageControl1.PageCount = 0 then begin 130 C1.Enabled := False; 131 L1.Enabled := False; 132 end; 133 end; 134 135 procedure TForm1.FileOpen1Accept(Sender: TObject); 136 var 137 pIndex: Integer; 138 fName: string; 139 begin 140 Add1.Click; 141 pIndex := PageControl1.ActivePageIndex; 142 fName := FileOpen1.Dialog.FileName; 143 TRecEdit(PageControl1.Pages[pIndex].Controls[0]).Lines.LoadFromFile(fName); 144 TRecEdit(PageControl1.Pages[pIndex].Controls[0]).fPath := fName; 145 PageControl1.ActivePage.Caption := ExtractFileName(fName); 146 //Form1.Caption := fName; 147 end; 148 149 procedure TForm1.FileSaveAs1Accept(Sender: TObject); 150 var 151 pIndex: Integer; 152 sPath: string; 153 begin 154 pIndex := PageControl1.ActivePageIndex; 155 sPath := FileSaveAs1.Dialog.FileName; 156 TRecEdit(PageControl1.Pages[pIndex].Controls[0]).Lines.SaveToFile(sPath); 157 TRecEdit(PageControl1.Pages[pIndex].Controls[0]).fPath := sPath; 158 end; 159 160 procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 161 begin 162 while PageControl1.PageCount > 0 do 163 if not ClosePageQuery() then begin 164 CanClose := True; 165 Exit; 166 end; 167 end; 168 169 procedure TForm1.FormCreate(Sender: TObject); 170 begin 171 n := 1; 172 N1.Click; 173 end; 174 175 procedure TForm1.N1Click(Sender: TObject); //新建 176 begin 177 Add1.Click; 178 PageControl1.ActivePage.Caption := '无标题' + IntToStr(n); 179 Inc(n); 180 end; 181 182 procedure TForm1.S1Click(Sender: TObject); //保存 183 var 184 s: string; 185 pIndex: Integer; 186 begin 187 with PageControl1 do begin 188 pIndex := ActivePageIndex; 189 s := TRecEdit(Pages[pIndex].Controls[0]).fPath; 190 if s = '' then begin 191 if SaveDialog1.Execute then begin 192 TRecEdit(Pages[pIndex].Controls[0]).Lines.SaveToFile(SaveDialog1.FileName); 193 TRecEdit(Pages[pIndex].Controls[0]).fPath = SaveDialog1.FileName; 194 end; 195 end else 196 if TRecEdit(Pages[pIndex].Controls[0]).Modified then 197 TRecEdit(Pages[pIndex].Controls[0]
首页 上一页 1 2 3 4 下一页 尾页 3/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇【转】Png异形窗口 下一篇【Asphyre引擎】发布了新版本V101

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目