-
unit Unit1;
-
-
interface
-
-
uses
-
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
-
Dialogs, ComCtrls, StdCtrls, ImgList, ToolWin, Menus;
-
-
type
-
TForm1 = class(TForm)
-
ImageList1: TImageList;
-
texto: TRichEdit;
-
StatusBar1: TStatusBar;
-
MainMenu1: TMainMenu;
-
tb: TToolBar;
-
ToolButton1: TToolButton;
-
ToolButton2: TToolButton;
-
ToolButton3: TToolButton;
-
save: TToolButton;
-
ToolButton5: TToolButton;
-
ToolButton6: TToolButton;
-
ToolButton8: TToolButton;
-
copiar: TToolButton;
-
cortar: TToolButton;
-
ToolButton12: TToolButton;
-
ToolButton13: TToolButton;
-
ToolButton14: TToolButton;
-
ToolButton15: TToolButton;
-
ToolButton16: TToolButton;
-
ToolButton17: TToolButton;
-
ToolButton18: TToolButton;
-
ToolButton19: TToolButton;
-
Archivo1: TMenuItem;
-
Edicion1: TMenuItem;
-
Formato1: TMenuItem;
-
Acercade1: TMenuItem;
-
Nuevo1: TMenuItem;
-
N1: TMenuItem;
-
Abrir1: TMenuItem;
-
Guardar1: TMenuItem;
-
Guardarcomo1: TMenuItem;
-
Imprimir1: TMenuItem;
-
Salir1: TMenuItem;
-
N2: TMenuItem;
-
Salir2: TMenuItem;
-
Deshacer1: TMenuItem;
-
N3: TMenuItem;
-
Cortar1: TMenuItem;
-
Copiar1: TMenuItem;
-
Pegar1: TMenuItem;
-
Borrar1: TMenuItem;
-
Seleccionartodo1: TMenuItem;
-
N4: TMenuItem;
-
Buscar1: TMenuItem;
-
Fuente1: TMenuItem;
-
Color1: TMenuItem;
-
Ayuda1: TMenuItem;
-
Acercadeleditordetexto1: TMenuItem;
-
OpenDialog1: TOpenDialog;
-
SaveDialog1: TSaveDialog;
-
FontDialog1: TFontDialog;
-
ColorDialog1: TColorDialog;
-
PrintDialog1: TPrintDialog;
-
FindDialog1: TFindDialog;
-
ReplaceDialog1: TReplaceDialog;
-
ToolButton24: TToolButton;
-
ToolButton25: TToolButton;
-
ToolBar1: TToolBar;
-
cb1: TComboBox;
-
cb2: TComboBox;
-
ToolButton4: TToolButton;
-
ToolButton7: TToolButton;
-
ToolButton9: TToolButton;
-
ToolButton10: TToolButton;
-
ToolButton11: TToolButton;
-
ToolButton20: TToolButton;
-
ToolButton21: TToolButton;
-
ToolButton22: TToolButton;
-
ToolButton23: TToolButton;
-
ToolButton26: TToolButton;
-
Fondo1: TMenuItem;
-
Remplazar1: TMenuItem;
-
procedure Salir2Click(Sender: TObject);
-
procedure ToolButton3Click(Sender: TObject);
-
procedure FormActivate(Sender: TObject);
-
procedure saveClick(Sender: TObject);
-
procedure textoChange(Sender: TObject);
-
procedure ToolButton6Click(Sender: TObject);
-
procedure Nuevo1Click(Sender: TObject);
-
procedure Abrir1Click(Sender: TObject);
-
procedure Guardar1Click(Sender: TObject);
-
procedure Salir1Click(Sender: TObject);
-
procedure Guardarcomo1Click(Sender: TObject);
-
procedure cb1Change(Sender: TObject);
-
procedure cb2Change(Sender: TObject);
-
procedure ToolButton17Click(Sender: TObject);
-
procedure ToolButton16Click(Sender: TObject);
-
procedure Fuente1Click(Sender: TObject);
-
procedure Color1Click(Sender: TObject);
-
procedure Borrar1Click(Sender: TObject);
-
procedure Seleccionartodo1Click(Sender: TObject);
-
procedure Cortar1Click(Sender: TObject);
-
procedure Copiar1Click(Sender: TObject);
-
procedure Pegar1Click(Sender: TObject);
-
procedure ToolButton12Click(Sender: TObject);
-
procedure copiarClick(Sender: TObject);
-
procedure cortarClick(Sender: TObject);
-
procedure textoMouseUp(Sender: TObject; Button: TMouseButton;
-
Shift: TShiftState; X, Y: Integer);
-
procedure ToolButton8Click(Sender: TObject);
-
procedure ToolButton14Click(Sender: TObject);
-
procedure Deshacer1Click(Sender: TObject);
-
procedure Acercadeleditordetexto1Click(Sender: TObject);
-
procedure Ayuda1Click(Sender: TObject);
-
procedure ToolButton19Click(Sender: TObject);
-
procedure ToolButton23Click(Sender: TObject);
-
procedure ToolButton22Click(Sender: TObject);
-
procedure ToolButton26Click(Sender: TObject);
-
procedure ToolButton10Click(Sender: TObject);
-
procedure ToolButton11Click(Sender: TObject);
-
procedure ToolButton20Click(Sender: TObject);
-
procedure FormCreate(Sender: TObject);
-
procedure Fondo1Click(Sender: TObject);
-
procedure Buscar1Click(Sender: TObject);
-
procedure Remplazar1Click(Sender: TObject);
-
procedure FindDialog1Find(Sender: TObject);
-
procedure ReplaceDialog1Find(Sender: TObject);
-
procedure ReplaceDialog1Replace(Sender: TObject);
-
procedure textoKeyUp(Sender: TObject; var Key: Word;
-
Shift: TShiftState);
-
procedure ToolButton1Click(Sender: TObject);
-
private
-
{ Private declarations }
-
public
-
{ Public declarations }
-
end;
-
-
var
-
Form1: TForm1;
-
ban1,ban2,ban3,ban4,ban5,ban6,c,a,b,ban:integer;
-
archivoo,archivos:string;
-
{ban1.-Documento abierto
-
ban2.-Nuevo documento
-
ban3.-Documento se guardo
-
ban4.-Documento abierto cambi贸}
-
-
implementation
-
-
uses Unit2, Unit3;
-
-
{$R *.dfm}
-
-
procedure TForm1.Salir2Click(Sender: TObject);
-
begin
-
if (ban1=1) then {1}
-
begin
-
if (ban4=1) then {2}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
form1.Close;
-
form2.Close;
-
form3.Close;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivoo);
-
form1.Close;
-
form2.Close;
-
form3.Close;
-
end;
-
end;
-
end {2}
-
else
-
begin
-
form1.Close;
-
form2.Close;
-
form3.Close;
-
end;
-
end {1}
-
else {1 else}
-
begin
-
if (ban6=0) then
-
begin
-
if (ban5=1) then {si cambi贸}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
form1.Close;
-
form2.Close;
-
form3.Close;
-
end;
-
{YES}
-
mryes:
-
begin
-
if (savedialog1.execute) then
-
begin
-
archivos:=savedialog1.filename;
-
texto.lines.Savetofile(savedialog1.filename);
-
form1.Close;
-
form2.Close;
-
form3.Close;
-
end;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
form1.Close;
-
form2.Close;
-
form3.Close;
-
end;
-
end;
-
-
if (ban6=1) then {si se guardo}
-
begin {-}
-
if (ban5=1) then {si cambio}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
form1.Close;
-
form2.Close;
-
form3.Close;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivos);
-
form1.Close;
-
form2.Close;
-
form3.Close;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
form1.Close;
-
form2.Close;
-
form3.Close;
-
end;
-
end; {-}
-
end; {1 else}
-
end;
-
-
procedure TForm1.ToolButton3Click(Sender: TObject);
-
begin
-
if (ban1=1) then {1}
-
begin
-
if (ban4=1) then {2}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivoo);
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end;
-
end {2}
-
else
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end {1}
-
else {1 else}
-
begin
-
if (ban6=0) then
-
begin
-
if (ban5=1) then {si cambi贸}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
{YES}
-
mryes:
-
begin
-
if (savedialog1.execute) then
-
begin
-
archivos:=savedialog1.filename;
-
texto.lines.Savetofile(savedialog1.filename);
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end;
-
-
if (ban6=1) then {si se guardo}
-
begin {-}
-
if (ban5=1) then {si cambio}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivos);
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end; {-}
-
end; {1 else}
-
end;
-
-
-
procedure TForm1.FormActivate(Sender: TObject);
-
begin
-
cb1.items:=screen.fonts;
-
form1.Show;
-
form2.hide;
-
form3.hide;
-
form1.setfocus;
-
end;
-
-
procedure TForm1.saveClick(Sender: TObject);
-
begin
-
if (ban1=1) then
-
texto.lines.Savetofile(archivoo)
-
else
-
begin
-
if (ban3=1) then
-
texto.lines.Savetofile(archivos)
-
else
-
begin
-
if (savedialog1.Execute) then
-
begin
-
archivos:=savedialog1.filename;
-
ban3:=1;
-
ban6:=1;
-
ban5:=0;
-
texto.lines.Savetofile(savedialog1.filename);
-
form1.caption:=savedialog1.filename + ' - Editor de Texto';
-
end;
-
end;
-
end;
-
end;
-
-
procedure TForm1.textoChange(Sender: TObject);
-
begin
-
if (ban1=1) then
-
begin
-
save.enabled:=true;
-
save.ImageIndex:=12;
-
ban4:=1;
-
statusbar1.Panels[2].Text:='Cambio';
-
end;
-
-
if (ban3=1) then
-
ban3:=0;
-
-
-
if (ban2=1) then
-
ban5:=1;
-
-
-
{contamos lineas y caracteres}
-
statusbar1.panels[1].Text:=inttostr(texto.lines.count)+' Lineas';
-
statusbar1.panels[0].Text:=inttostr(length(texto.text))+ ' Caracteres';
-
-
{bloqueamos botones}
-
if (texto.SelLength>0) then
-
begin
-
copiar.ImageIndex:=4;
-
copiar.enabled:=true;
-
cortar.ImageIndex:=6;
-
cortar.enabled:=true;
-
copiar1.enabled:=true;
-
cortar1.enabled:=true;
-
end
-
else
-
begin
-
copiar.ImageIndex:=5;
-
copiar.enabled:=false;
-
cortar.ImageIndex:=7;
-
cortar.enabled:=false;
-
copiar1.enabled:=false;
-
cortar1.enabled:=false;
-
end;
-
end;
-
-
procedure TForm1.ToolButton6Click(Sender: TObject);
-
begin
-
if (ban1=1) or (ban3=1) then
-
begin
-
if (ban1=1) then
-
begin
-
if (printdialog1.execute) then
-
texto.print(archivoo);
-
end;
-
-
if (ban3=1) then
-
begin
-
if (printdialog1.execute) then
-
texto.print(archivos);
-
end;
-
end
-
else
-
if (printdialog1.execute) then
-
texto.print('Documento.rtf');
-
end;
-
-
procedure TForm1.Nuevo1Click(Sender: TObject);
-
begin
-
if (ban1=1) then {1}
-
begin
-
if (ban4=1) then {2}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivoo);
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end;
-
end {2}
-
else
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end {1}
-
else {1 else}
-
begin
-
if (ban6=0) then
-
begin
-
if (ban5=1) then {si cambi贸}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
{YES}
-
mryes:
-
begin
-
if (savedialog1.execute) then
-
begin
-
archivos:=savedialog1.filename;
-
texto.lines.Savetofile(savedialog1.filename);
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end;
-
-
if (ban6=1) then {si se guardo}
-
begin {-}
-
if (ban5=1) then {si cambio}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivos);
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end; {-}
-
end; {1 else}
-
end;
-
-
procedure TForm1.Abrir1Click(Sender: TObject);
-
begin
-
if (ban1=1) then {1}
-
begin
-
if (ban4=1) then {2}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivoo);
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end;
-
end {2}
-
else
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end {1}
-
else {1 else}
-
begin
-
if (ban6=0) then
-
begin
-
if (ban5=1) then {si cambi贸}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
{YES}
-
mryes:
-
begin
-
if (savedialog1.execute) then
-
begin
-
archivos:=savedialog1.filename;
-
texto.lines.Savetofile(savedialog1.filename);
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end;
-
-
if (ban6=1) then {si se guardo}
-
begin {-}
-
if (ban5=1) then {si cambio}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivos);
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
if opendialog1.execute then
-
begin
-
archivoo:=opendialog1.filename;
-
texto.Lines.loadfromfile(opendialog1.filename);
-
form1.caption:=opendialog1.filename + ' - Editor de Texto';
-
ban1:=1;
-
ban2:=0;
-
ban4:=0;
-
ban3:=0;
-
ban5:=0;
-
ban6:=0;
-
save.enabled:=false;
-
save.ImageIndex:=13;
-
end;
-
end;
-
end; {-}
-
end; {1 else}
-
end;
-
-
procedure TForm1.Guardar1Click(Sender: TObject);
-
begin
-
if (ban1=1) then
-
texto.lines.Savetofile(archivoo)
-
else
-
begin
-
if (ban3=1) then
-
texto.lines.Savetofile(archivos)
-
else
-
begin
-
if (savedialog1.Execute) then
-
begin
-
archivos:=savedialog1.filename;
-
ban3:=1;
-
texto.lines.Savetofile(savedialog1.filename);
-
form1.caption:=savedialog1.filename + ' - Editor de Texto';
-
end;
-
end;
-
end;
-
end;
-
-
procedure TForm1.Salir1Click(Sender: TObject);
-
begin
-
if (ban1=1) or (ban3=1) then
-
begin
-
if (ban1=1) then
-
begin
-
if (printdialog1.execute) then
-
texto.print(archivoo);
-
end;
-
-
if (ban3=1) then
-
begin
-
if (printdialog1.execute) then
-
texto.print(archivos);
-
end;
-
end
-
else
-
if (printdialog1.execute) then
-
texto.print('Documento.rtf');
-
end;
-
-
procedure TForm1.Guardarcomo1Click(Sender: TObject);
-
begin
-
if (savedialog1.Execute) then
-
begin
-
archivos:=savedialog1.filename;
-
ban3:=1;
-
texto.lines.Savetofile(savedialog1.filename);
-
form1.caption:=savedialog1.filename + ' - Editor de Texto';
-
end;
-
end;
-
-
procedure TForm1.cb1Change(Sender: TObject);
-
begin
-
texto.SelAttributes.Name:=cb1.Text;
-
end;
-
-
procedure TForm1.cb2Change(Sender: TObject);
-
begin
-
if (cb2.text<>'') then
-
texto.SelAttributes.size:=strtoint(cb2.Text);
-
end;
-
-
procedure TForm1.ToolButton17Click(Sender: TObject);
-
begin
-
if (colordialog1.execute) then
-
texto.SelAttributes.Color:=colordialog1.Color;
-
end;
-
-
procedure TForm1.ToolButton16Click(Sender: TObject);
-
begin
-
if (fontdialog1.execute) then
-
begin
-
texto.SelAttributes.Name:=fontdialog1.font.Name;
-
texto.SelAttributes.size:=fontdialog1.Font.size;
-
texto.SelAttributes.style:=fontdialog1.font.style;
-
texto.SelAttributes.color:=fontdialog1.font.color;
-
end;
-
end;
-
-
procedure TForm1.Fuente1Click(Sender: TObject);
-
begin
-
if (fontdialog1.execute) then
-
begin
-
texto.SelAttributes.Name:=fontdialog1.font.Name;
-
texto.SelAttributes.size:=fontdialog1.Font.size;
-
texto.SelAttributes.style:=fontdialog1.font.style;
-
texto.SelAttributes.color:=fontdialog1.font.color;
-
end;
-
end;
-
-
procedure TForm1.Color1Click(Sender: TObject);
-
begin
-
if (colordialog1.execute) then
-
texto.SelAttributes.Color:=colordialog1.Color;
-
end;
-
-
procedure TForm1.Borrar1Click(Sender: TObject);
-
begin
-
texto.ClearSelection;
-
end;
-
-
procedure TForm1.Seleccionartodo1Click(Sender: TObject);
-
begin
-
texto.selectall;
-
end;
-
-
procedure TForm1.Cortar1Click(Sender: TObject);
-
begin
-
texto.cuttoclipboard;
-
end;
-
-
procedure TForm1.Copiar1Click(Sender: TObject);
-
begin
-
texto.CopyToClipboard;
-
end;
-
-
procedure TForm1.Pegar1Click(Sender: TObject);
-
begin
-
texto.pastefromclipboard;
-
end;
-
-
procedure TForm1.ToolButton12Click(Sender: TObject);
-
begin
-
texto.pastefromclipboard;
-
end;
-
-
procedure TForm1.copiarClick(Sender: TObject);
-
begin
-
texto.CopyToClipboard;
-
end;
-
-
procedure TForm1.cortarClick(Sender: TObject);
-
begin
-
texto.cuttoclipboard;
-
end;
-
-
procedure TForm1.textoMouseUp(Sender: TObject; Button: TMouseButton;
-
Shift: TShiftState; X, Y: Integer);
-
begin
-
{bloqueamos botones}
-
if (texto.SelLength>0) then
-
begin
-
copiar.ImageIndex:=4;
-
copiar.enabled:=true;
-
cortar.ImageIndex:=6;
-
cortar.enabled:=true;
-
copiar1.enabled:=true;
-
cortar1.enabled:=true;
-
end
-
else
-
begin
-
copiar.ImageIndex:=5;
-
copiar.enabled:=false;
-
cortar.ImageIndex:=7;
-
cortar.enabled:=false;
-
copiar1.enabled:=false;
-
cortar1.enabled:=false;
-
end;
-
end;
-
-
procedure TForm1.ToolButton8Click(Sender: TObject);
-
begin
-
if (texto.canundo) then
-
texto.Undo;
-
end;
-
-
procedure TForm1.ToolButton14Click(Sender: TObject);
-
begin
-
texto.clearundo;
-
end;
-
-
procedure TForm1.Deshacer1Click(Sender: TObject);
-
begin
-
if (texto.canundo) then
-
texto.Undo;
-
end;
-
-
procedure TForm1.Acercadeleditordetexto1Click(Sender: TObject);
-
begin
-
form2.show;
-
end;
-
-
procedure TForm1.Ayuda1Click(Sender: TObject);
-
begin
-
form3.show;
-
end;
-
-
procedure TForm1.ToolButton19Click(Sender: TObject);
-
begin
-
form3.show;
-
end;
-
-
procedure TForm1.ToolButton23Click(Sender: TObject);
-
begin
-
texto.Paragraph.Alignment:=tacenter;
-
end;
-
-
procedure TForm1.ToolButton22Click(Sender: TObject);
-
begin
-
texto.Paragraph.alignment:=taleftjustify;
-
end;
-
-
procedure TForm1.ToolButton26Click(Sender: TObject);
-
begin
-
texto.paragraph.alignment:=tarightjustify;
-
end;
-
-
procedure TForm1.ToolButton10Click(Sender: TObject);
-
begin
-
for c:=1 to 1 do
-
begin
-
{1}
-
if (texto.SelAttributes.Style=[fsbold]) then
-
begin
-
texto.SelAttributes.Style:=[];
-
break;
-
end;
-
{2}
-
if (texto.SelAttributes.Style=[]) then
-
begin
-
texto.SelAttributes.Style:=[fsbold];
-
break;
-
end;
-
{3}
-
if (texto.SelAttributes.Style=[fsbold, fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsitalic];
-
break;
-
end;
-
{4}
-
if (texto.SelAttributes.Style=[fsbold, fsunderline]) then
-
begin
-
texto.SelAttributes.Style:=[fsunderline];
-
break;
-
end;
-
{5}
-
if (texto.SelAttributes.Style=[fsbold, fsunderline, fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsunderline, fsitalic];
-
break;
-
end;
-
{6}
-
if (texto.SelAttributes.Style=[fsunderline, fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsunderline, fsitalic, fsbold];
-
break;
-
end;
-
{7}
-
if (texto.SelAttributes.Style=[fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsbold, fsitalic];
-
break;
-
end;
-
{8}
-
if (texto.SelAttributes.Style=[fsunderline]) then
-
begin
-
texto.SelAttributes.Style:=[fsbold, fsunderline];
-
break;
-
end;
-
end;
-
end;
-
-
procedure TForm1.ToolButton11Click(Sender: TObject);
-
begin
-
for c:=1 to 1 do
-
begin
-
{1}
-
if (texto.SelAttributes.Style=[fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[];
-
break;
-
end;
-
{2}
-
if (texto.SelAttributes.Style=[]) then
-
begin
-
texto.SelAttributes.Style:=[fsitalic];
-
break;
-
end;
-
{3}
-
if (texto.SelAttributes.Style=[fsbold, fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsbold];
-
break;
-
end;
-
{4}
-
if (texto.SelAttributes.Style=[fsitalic, fsunderline]) then
-
begin
-
texto.SelAttributes.Style:=[fsunderline];
-
break;
-
end;
-
{5}
-
if (texto.SelAttributes.Style=[fsbold, fsunderline, fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsbold, fsunderline];
-
break;
-
end;
-
{6}
-
if (texto.SelAttributes.Style=[fsunderline, fsbold]) then
-
begin
-
texto.SelAttributes.Style:=[fsunderline, fsitalic, fsbold];
-
break;
-
end;
-
{7}
-
if (texto.SelAttributes.Style=[fsbold]) then
-
begin
-
texto.SelAttributes.Style:=[fsbold, fsitalic];
-
break;
-
end;
-
{8}
-
if (texto.SelAttributes.Style=[fsunderline]) then
-
begin
-
texto.SelAttributes.Style:=[fsitalic, fsunderline];
-
break;
-
end;
-
end;
-
end;
-
-
procedure TForm1.ToolButton20Click(Sender: TObject);
-
begin
-
for c:=1 to 1 do
-
begin
-
{1}
-
if (texto.SelAttributes.Style=[fsunderline]) then
-
begin
-
texto.SelAttributes.Style:=[];
-
break;
-
end;
-
{2}
-
if (texto.SelAttributes.Style=[]) then
-
begin
-
texto.SelAttributes.Style:=[fsunderline];
-
break;
-
end;
-
{3}
-
if (texto.SelAttributes.Style=[fsunderline, fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsitalic];
-
break;
-
end;
-
{4}
-
if (texto.SelAttributes.Style=[fsbold, fsunderline]) then
-
begin
-
texto.SelAttributes.Style:=[fsbold];
-
break;
-
end;
-
{5}
-
if (texto.SelAttributes.Style=[fsbold, fsunderline, fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsbold, fsitalic];
-
break;
-
end;
-
{6}
-
if (texto.SelAttributes.Style=[fsbold, fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsunderline, fsitalic, fsbold];
-
break;
-
end;
-
{7}
-
if (texto.SelAttributes.Style=[fsitalic]) then
-
begin
-
texto.SelAttributes.Style:=[fsunderline, fsitalic];
-
break;
-
end;
-
{8}
-
if (texto.SelAttributes.Style=[fsbold]) then
-
begin
-
texto.SelAttributes.Style:=[fsbold, fsunderline];
-
break;
-
end;
-
end;
-
end;
-
-
procedure TForm1.FormCreate(Sender: TObject);
-
begin
-
ban1:=0;
-
ban2:=1;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
texto.SelAttributes.Name:='Tahoma';
-
end;
-
-
procedure TForm1.Fondo1Click(Sender: TObject);
-
begin
-
if (colordialog1.execute) then
-
texto.Color:=colordialog1.Color;
-
end;
-
-
procedure TForm1.Buscar1Click(Sender: TObject);
-
begin
-
finddialog1.Execute;
-
end;
-
-
procedure TForm1.Remplazar1Click(Sender: TObject);
-
begin
-
replacedialog1.Execute;
-
ban:=0;
-
end;
-
-
procedure TForm1.FindDialog1Find(Sender: TObject);
-
begin
-
a:=0;
-
a:=texto.FindText(finddialog1.FindText, 0, length(texto.text), [stmatchcase]);
-
if (a>-1) then
-
begin
-
texto.SetFocus;
-
texto.selstart:=a;
-
texto.sellength:=length(finddialog1.findtext);
-
end
-
else
-
messagedlg('No se encontr贸 el texto buscado',mtinformation, [mbok], 0);
-
end;
-
-
procedure TForm1.ReplaceDialog1Find(Sender: TObject);
-
begin
-
a:=0;
-
a:=texto.FindText(replacedialog1.FindText, 0, length(texto.text), [stmatchcase]);
-
if (a>-1) then
-
begin
-
texto.SetFocus;
-
texto.selstart:=a;
-
texto.sellength:=length(replacedialog1.findtext);
-
end
-
else
-
messagedlg('No se encontr贸 el texto buscado',mtinformation, [mbok], 0);
-
end;
-
-
procedure TForm1.ReplaceDialog1Replace(Sender: TObject);
-
begin
-
if (a>-1) and (ban=0)then
-
begin
-
ban:=1;
-
a:=texto.FindText(replacedialog1.FindText, 0, length(texto.text), [stmatchcase]);
-
texto.SetFocus;
-
texto.selstart:=a;
-
texto.sellength:=length(replacedialog1.findtext);
-
texto.SelText:=replacedialog1.ReplaceText;
-
end
-
else
-
messagedlg('No se encontr贸 texto para reemplazar',mtinformation, [mbok], 0);
-
end;
-
-
procedure TForm1.textoKeyUp(Sender: TObject; var Key: Word;
-
Shift: TShiftState);
-
begin
-
{bloqueamos botones}
-
if (texto.SelLength>0) then
-
begin
-
copiar.ImageIndex:=4;
-
copiar.enabled:=true;
-
cortar.ImageIndex:=6;
-
cortar.enabled:=true;
-
copiar1.enabled:=true;
-
cortar1.enabled:=true;
-
end
-
else
-
begin
-
copiar.ImageIndex:=5;
-
copiar.enabled:=false;
-
cortar.ImageIndex:=7;
-
cortar.enabled:=false;
-
copiar1.enabled:=false;
-
cortar1.enabled:=false;
-
end;
-
end;
-
-
procedure TForm1.ToolButton1Click(Sender: TObject);
-
begin
-
if (ban1=1) then {1}
-
begin
-
if (ban4=1) then {2}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivoo);
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end;
-
end {2}
-
else
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end {1}
-
else {1 else}
-
begin
-
if (ban6=0) then
-
begin
-
if (ban5=1) then {si cambi贸}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
{YES}
-
mryes:
-
begin
-
if (savedialog1.execute) then
-
begin
-
archivos:=savedialog1.filename;
-
texto.lines.Savetofile(savedialog1.filename);
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end;
-
-
if (ban6=1) then {si se guardo}
-
begin {-}
-
if (ban5=1) then {si cambio}
-
begin
-
case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
-
[mbyes,mbno,mbcancel],0) of
-
{NO}
-
mrno:
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
{YES}
-
mryes:
-
begin
-
texto.lines.Savetofile(archivos);
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end; {case}
-
end
-
else {si no cambi贸}
-
begin
-
texto.Text:='';
-
form1.caption:='Documento - Editor de Texto';
-
ban2:=1;
-
ban1:=0;
-
ban3:=0;
-
ban4:=0;
-
ban5:=0;
-
ban6:=0;
-
end;
-
end; {-}
-
end; {1 else}
-
end;
-
-
end.
Paola
March 4th, 2008 at 12:04 pm
Felicidades!!!
Es un gran trabajo ;D
gerard
June 5th, 2008 at 12:33 pm
Estava buscando como usar el RichEdit con delphi y mira un ejemplo de lo mas completo, mil gracias!!!!
Antonio
September 28th, 2008 at 9:51 am
Muchas gracias, por decir algo negativo, solamenrte agregar resaltar fondo a un texto, y perfecto.
Muchas gracias, otra vez.
Antonio.
bettyy
October 9th, 2008 at 11:13 am
buen trabajoo gracias me sirvio de mucho!