{
Saya Pernah mencoba membuat Applikasi Notepad dengan Rich Edit,
Ketika Saya simpan ke Format *.txt,
Tampak seperti Gambar diatas.
}
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls, ComCtrls;
type
TForm1 = class(TForm)
RE: TRichEdit;
MM: TMainMenu;
OD: TOpenDialog;
SD: TSaveDialog;
File1: TMenuItem;
New1: TMenuItem;
Open1: TMenuItem;
SaveAs1: TMenuItem;
N1: TMenuItem;
Exit1: TMenuItem;
procedure Exit1Click(Sender: TObject);
procedure New1Click(Sender: TObject);
procedure Open1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure SaveAs1Click(Sender: TObject);
private
{ URL : http://amateur-guide.blogspot.com }
public
{ By : Zephio }
end;
var
Form1: TForm1;
Const
DS : String = 'Untitled - [ Zephio Pad ]';
implementation
{$R *.dfm}
procedure TForm1.Exit1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.New1Click(Sender: TObject);
begin
RE.Clear;
Caption := DS;
end;
procedure TForm1.Open1Click(Sender: TObject);
begin
OD.DefaultExt := '*.*';
OD.Filter := 'Any Files|*.*';
if not OD.Execute then
Exit;
RE.Lines.LoadFromFile(OD.FileName);
Caption := ChangeFileExt(ExtractFileName(OD.FileName), ' - [ Zephio Pad ]');
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
SD.DefaultExt := '*.rtf;*.wri;*.txt';
Caption := DS;
Application.Title := 'Zephio Pad';
end;
procedure TForm1.SaveAs1Click(Sender: TObject);
var
SL : TStringList;
begin
SL := TStringList.Create;
SL.Add(RE.Lines.Text);
if not SD.Execute then
Exit;
if LowerCase(ExtractFileExt(SD.FileName)) = '.rtf' then
begin
RE.Lines.SaveToFile(SD.FileName)
end
else
if LowerCase(ExtractFileExt(SD.FileName)) = '.wri' then
begin
RE.Lines.SaveToFile(SD.FileName)
end
else
if LowerCase(ExtractFileExt(SD.FileName)) = '.txt' then
SL.SaveToFile(SD.FileName);
SL.Free
end;
end.
No comments:
Post a Comment