Buenas :D pues este fue el proyecto final de mi tercera parcial en el Bachillerato 1 en la materia de Programaci贸n III jeje y pues si dur茅 algo haciendolo pero al final me quedo bien... no me puedo quejar, y aqu铆 lo comparto con ustedes por si alguien lo desea... La mayor ventaja que le he visto es que sirve mucho para probar las distintas fuentes (fonts) que tengo instaladas en mi compu, ya que es muy rapido con el procesamiento del texto con algunas fuentes pesadas...

Este es un screenshot de como es el editor:

Y aqu铆 esta el codigo fuente:

Form1

DELPHI:
  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, ComCtrls, StdCtrls, ImgList, ToolWin, Menus;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     ImageList1: TImageList;
  12.     texto: TRichEdit;
  13.     StatusBar1: TStatusBar;
  14.     MainMenu1: TMainMenu;
  15.     tb: TToolBar;
  16.     ToolButton1: TToolButton;
  17.     ToolButton2: TToolButton;
  18.     ToolButton3: TToolButton;
  19.     save: TToolButton;
  20.     ToolButton5: TToolButton;
  21.     ToolButton6: TToolButton;
  22.     ToolButton8: TToolButton;
  23.     copiar: TToolButton;
  24.     cortar: TToolButton;
  25.     ToolButton12: TToolButton;
  26.     ToolButton13: TToolButton;
  27.     ToolButton14: TToolButton;
  28.     ToolButton15: TToolButton;
  29.     ToolButton16: TToolButton;
  30.     ToolButton17: TToolButton;
  31.     ToolButton18: TToolButton;
  32.     ToolButton19: TToolButton;
  33.     Archivo1: TMenuItem;
  34.     Edicion1: TMenuItem;
  35.     Formato1: TMenuItem;
  36.     Acercade1: TMenuItem;
  37.     Nuevo1: TMenuItem;
  38.     N1: TMenuItem;
  39.     Abrir1: TMenuItem;
  40.     Guardar1: TMenuItem;
  41.     Guardarcomo1: TMenuItem;
  42.     Imprimir1: TMenuItem;
  43.     Salir1: TMenuItem;
  44.     N2: TMenuItem;
  45.     Salir2: TMenuItem;
  46.     Deshacer1: TMenuItem;
  47.     N3: TMenuItem;
  48.     Cortar1: TMenuItem;
  49.     Copiar1: TMenuItem;
  50.     Pegar1: TMenuItem;
  51.     Borrar1: TMenuItem;
  52.     Seleccionartodo1: TMenuItem;
  53.     N4: TMenuItem;
  54.     Buscar1: TMenuItem;
  55.     Fuente1: TMenuItem;
  56.     Color1: TMenuItem;
  57.     Ayuda1: TMenuItem;
  58.     Acercadeleditordetexto1: TMenuItem;
  59.     OpenDialog1: TOpenDialog;
  60.     SaveDialog1: TSaveDialog;
  61.     FontDialog1: TFontDialog;
  62.     ColorDialog1: TColorDialog;
  63.     PrintDialog1: TPrintDialog;
  64.     FindDialog1: TFindDialog;
  65.     ReplaceDialog1: TReplaceDialog;
  66.     ToolButton24: TToolButton;
  67.     ToolButton25: TToolButton;
  68.     ToolBar1: TToolBar;
  69.     cb1: TComboBox;
  70.     cb2: TComboBox;
  71.     ToolButton4: TToolButton;
  72.     ToolButton7: TToolButton;
  73.     ToolButton9: TToolButton;
  74.     ToolButton10: TToolButton;
  75.     ToolButton11: TToolButton;
  76.     ToolButton20: TToolButton;
  77.     ToolButton21: TToolButton;
  78.     ToolButton22: TToolButton;
  79.     ToolButton23: TToolButton;
  80.     ToolButton26: TToolButton;
  81.     Fondo1: TMenuItem;
  82.     Remplazar1: TMenuItem;
  83.     procedure Salir2Click(Sender: TObject);
  84.     procedure ToolButton3Click(Sender: TObject);
  85.     procedure FormActivate(Sender: TObject);
  86.     procedure saveClick(Sender: TObject);
  87.     procedure textoChange(Sender: TObject);
  88.     procedure ToolButton6Click(Sender: TObject);
  89.     procedure Nuevo1Click(Sender: TObject);
  90.     procedure Abrir1Click(Sender: TObject);
  91.     procedure Guardar1Click(Sender: TObject);
  92.     procedure Salir1Click(Sender: TObject);
  93.     procedure Guardarcomo1Click(Sender: TObject);
  94.     procedure cb1Change(Sender: TObject);
  95.     procedure cb2Change(Sender: TObject);
  96.     procedure ToolButton17Click(Sender: TObject);
  97.     procedure ToolButton16Click(Sender: TObject);
  98.     procedure Fuente1Click(Sender: TObject);
  99.     procedure Color1Click(Sender: TObject);
  100.     procedure Borrar1Click(Sender: TObject);
  101.     procedure Seleccionartodo1Click(Sender: TObject);
  102.     procedure Cortar1Click(Sender: TObject);
  103.     procedure Copiar1Click(Sender: TObject);
  104.     procedure Pegar1Click(Sender: TObject);
  105.     procedure ToolButton12Click(Sender: TObject);
  106.     procedure copiarClick(Sender: TObject);
  107.     procedure cortarClick(Sender: TObject);
  108.     procedure textoMouseUp(Sender: TObject; Button: TMouseButton;
  109.       Shift: TShiftState; X, Y: Integer);
  110.     procedure ToolButton8Click(Sender: TObject);
  111.     procedure ToolButton14Click(Sender: TObject);
  112.     procedure Deshacer1Click(Sender: TObject);
  113.     procedure Acercadeleditordetexto1Click(Sender: TObject);
  114.     procedure Ayuda1Click(Sender: TObject);
  115.     procedure ToolButton19Click(Sender: TObject);
  116.     procedure ToolButton23Click(Sender: TObject);
  117.     procedure ToolButton22Click(Sender: TObject);
  118.     procedure ToolButton26Click(Sender: TObject);
  119.     procedure ToolButton10Click(Sender: TObject);
  120.     procedure ToolButton11Click(Sender: TObject);
  121.     procedure ToolButton20Click(Sender: TObject);
  122.     procedure FormCreate(Sender: TObject);
  123.     procedure Fondo1Click(Sender: TObject);
  124.     procedure Buscar1Click(Sender: TObject);
  125.     procedure Remplazar1Click(Sender: TObject);
  126.     procedure FindDialog1Find(Sender: TObject);
  127.     procedure ReplaceDialog1Find(Sender: TObject);
  128.     procedure ReplaceDialog1Replace(Sender: TObject);
  129.     procedure textoKeyUp(Sender: TObject; var Key: Word;
  130.       Shift: TShiftState);
  131.     procedure ToolButton1Click(Sender: TObject);
  132.   private
  133.     { Private declarations }
  134.   public
  135.     { Public declarations }
  136.   end;
  137.  
  138. var
  139.   Form1: TForm1;
  140.   ban1,ban2,ban3,ban4,ban5,ban6,c,a,b,ban:integer;
  141.   archivoo,archivos:string;
  142.   {ban1.-Documento abierto
  143.    ban2.-Nuevo documento
  144.    ban3.-Documento se guardo
  145.    ban4.-Documento abierto cambi贸}
  146.  
  147. implementation
  148.  
  149. uses Unit2, Unit3;
  150.  
  151. {$R *.dfm}
  152.  
  153. procedure TForm1.Salir2Click(Sender: TObject);
  154. begin
  155.   if (ban1=1) then       {1}
  156.     begin
  157.     if (ban4=1) then       {2}
  158.       begin
  159.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  160.       [mbyes,mbno,mbcancel],0) of
  161.       {NO}
  162.       mrno:
  163.         begin
  164.         form1.Close;
  165.         form2.Close;
  166.         form3.Close;
  167.         end;
  168.       {YES}
  169.       mryes:
  170.         begin
  171.         texto.lines.Savetofile(archivoo);
  172.         form1.Close;
  173.         form2.Close;
  174.         form3.Close;
  175.         end;
  176.       end;
  177.      end {2}
  178.     else
  179.       begin
  180.       form1.Close;
  181.       form2.Close;
  182.       form3.Close;
  183.       end;
  184.     end  {1}
  185.   else  {1 else}
  186.     begin
  187.     if (ban6=0) then
  188.     begin
  189.     if (ban5=1) then      {si cambi贸}
  190.       begin
  191.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  192.       [mbyes,mbno,mbcancel],0) of
  193.         {NO}
  194.         mrno:
  195.           begin
  196.           form1.Close;
  197.           form2.Close;
  198.           form3.Close;
  199.           end;
  200.         {YES}
  201.         mryes:
  202.           begin
  203.           if (savedialog1.execute) then
  204.             begin
  205.             archivos:=savedialog1.filename;
  206.             texto.lines.Savetofile(savedialog1.filename);
  207.             form1.Close;
  208.             form2.Close;
  209.             form3.Close;
  210.             end;
  211.           end;
  212.        end;   {case}
  213.       end
  214.     else                  {si no cambi贸}
  215.       begin
  216.       form1.Close;
  217.       form2.Close;
  218.       form3.Close;
  219.       end;
  220.     end;
  221.  
  222.     if (ban6=1) then     {si se guardo}
  223.       begin  {-}
  224.       if (ban5=1) then    {si cambio}
  225.         begin
  226.         case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  227.         [mbyes,mbno,mbcancel],0) of
  228.           {NO}
  229.           mrno:
  230.             begin
  231.             form1.Close;
  232.             form2.Close;
  233.             form3.Close;
  234.             end;
  235.           {YES}
  236.           mryes:
  237.             begin
  238.             texto.lines.Savetofile(archivos);
  239.             form1.Close;
  240.             form2.Close;
  241.             form3.Close;
  242.             end;
  243.          end;   {case}
  244.         end
  245.       else                  {si no cambi贸}
  246.         begin
  247.         form1.Close;
  248.         form2.Close;
  249.         form3.Close;
  250.         end;
  251.       end{-}
  252.     end;   {1 else}
  253. end;
  254.  
  255. procedure TForm1.ToolButton3Click(Sender: TObject);
  256. begin
  257.   if (ban1=1) then       {1}
  258.     begin
  259.     if (ban4=1) then       {2}
  260.       begin
  261.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  262.       [mbyes,mbno,mbcancel],0) of
  263.       {NO}
  264.       mrno:
  265.         begin
  266.         if opendialog1.execute then
  267.           begin
  268.           archivoo:=opendialog1.filename;
  269.           texto.Lines.loadfromfile(opendialog1.filename);
  270.           form1.caption:=opendialog1.filename + ' - Editor de Texto';
  271.           ban1:=1;
  272.           ban2:=0;
  273.           ban4:=0;
  274.           ban3:=0;
  275.           ban5:=0;
  276.           ban6:=0;
  277.           save.enabled:=false;
  278.           save.ImageIndex:=13;
  279.           end;
  280.         end;
  281.       {YES}
  282.       mryes:
  283.         begin
  284.         texto.lines.Savetofile(archivoo);
  285.         if opendialog1.execute then
  286.           begin
  287.           archivoo:=opendialog1.filename;
  288.           texto.Lines.loadfromfile(opendialog1.filename);
  289.           form1.caption:=opendialog1.filename + ' - Editor de Texto';
  290.           ban1:=1;
  291.           ban2:=0;
  292.           ban4:=0;
  293.           ban3:=0;
  294.           ban5:=0;
  295.           ban6:=0;
  296.           save.enabled:=false;
  297.           save.ImageIndex:=13;
  298.           end;
  299.         end;
  300.       end;
  301.      end {2}
  302.     else
  303.       begin
  304.       if opendialog1.execute then
  305.         begin
  306.         archivoo:=opendialog1.filename;
  307.         texto.Lines.loadfromfile(opendialog1.filename);
  308.         form1.caption:=opendialog1.filename + ' - Editor de Texto';
  309.         ban1:=1;
  310.         ban2:=0;
  311.         ban4:=0;
  312.         ban3:=0;
  313.         ban5:=0;
  314.         ban6:=0;
  315.         save.enabled:=false;
  316.         save.ImageIndex:=13;
  317.         end;
  318.       end;
  319.     end  {1}
  320.   else  {1 else}
  321.     begin
  322.     if (ban6=0) then
  323.     begin
  324.     if (ban5=1) then      {si cambi贸}
  325.       begin
  326.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  327.       [mbyes,mbno,mbcancel],0) of
  328.         {NO}
  329.         mrno:
  330.           begin
  331.           if opendialog1.execute then
  332.             begin
  333.             archivoo:=opendialog1.filename;
  334.             texto.Lines.loadfromfile(opendialog1.filename);
  335.             form1.caption:=opendialog1.filename + ' - Editor de Texto';
  336.             ban1:=1;
  337.             ban2:=0;
  338.             ban4:=0;
  339.             ban3:=0;
  340.             ban5:=0;
  341.             ban6:=0;
  342.             save.enabled:=false;
  343.             save.ImageIndex:=13;
  344.             end;
  345.           end;
  346.         {YES}
  347.         mryes:
  348.           begin
  349.           if (savedialog1.execute) then
  350.             begin
  351.             archivos:=savedialog1.filename;
  352.             texto.lines.Savetofile(savedialog1.filename);
  353.             if opendialog1.execute then
  354.               begin
  355.               archivoo:=opendialog1.filename;
  356.               texto.Lines.loadfromfile(opendialog1.filename);
  357.               form1.caption:=opendialog1.filename + ' - Editor de Texto';
  358.               ban1:=1;
  359.               ban2:=0;
  360.               ban4:=0;
  361.               ban3:=0;
  362.               ban5:=0;
  363.               ban6:=0;
  364.               save.enabled:=false;
  365.               save.ImageIndex:=13;
  366.               end;
  367.             end;
  368.           end;
  369.        end;   {case}
  370.       end
  371.     else                  {si no cambi贸}
  372.       begin
  373.       if opendialog1.execute then
  374.         begin
  375.         archivoo:=opendialog1.filename;
  376.         texto.Lines.loadfromfile(opendialog1.filename);
  377.         form1.caption:=opendialog1.filename + ' - Editor de Texto';
  378.         ban1:=1;
  379.         ban2:=0;
  380.         ban4:=0;
  381.         ban3:=0;
  382.         ban5:=0;
  383.         ban6:=0;
  384.         save.enabled:=false;
  385.         save.ImageIndex:=13;
  386.         end;
  387.       end;
  388.     end;
  389.  
  390.     if (ban6=1) then     {si se guardo}
  391.       begin  {-}
  392.       if (ban5=1) then    {si cambio}
  393.         begin
  394.         case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  395.         [mbyes,mbno,mbcancel],0) of
  396.           {NO}
  397.           mrno:
  398.             begin
  399.             if opendialog1.execute then
  400.               begin
  401.               archivoo:=opendialog1.filename;
  402.               texto.Lines.loadfromfile(opendialog1.filename);
  403.               form1.caption:=opendialog1.filename + ' - Editor de Texto';
  404.               ban1:=1;
  405.               ban2:=0;
  406.               ban4:=0;
  407.               ban3:=0;
  408.               ban5:=0;
  409.               ban6:=0;
  410.               save.enabled:=false;
  411.               save.ImageIndex:=13;
  412.               end;
  413.             end;
  414.           {YES}
  415.           mryes:
  416.             begin
  417.             texto.lines.Savetofile(archivos);
  418.             if opendialog1.execute then
  419.               begin
  420.               archivoo:=opendialog1.filename;
  421.               texto.Lines.loadfromfile(opendialog1.filename);
  422.               form1.caption:=opendialog1.filename + ' - Editor de Texto';
  423.               ban1:=1;
  424.               ban2:=0;
  425.               ban4:=0;
  426.               ban3:=0;
  427.               ban5:=0;
  428.               ban6:=0;
  429.               save.enabled:=false;
  430.               save.ImageIndex:=13;
  431.               end;
  432.             end;
  433.          end;   {case}
  434.         end
  435.       else                  {si no cambi贸}
  436.         begin
  437.         if opendialog1.execute then
  438.           begin
  439.           archivoo:=opendialog1.filename;
  440.           texto.Lines.loadfromfile(opendialog1.filename);
  441.           form1.caption:=opendialog1.filename + ' - Editor de Texto';
  442.           ban1:=1;
  443.           ban2:=0;
  444.           ban4:=0;
  445.           ban3:=0;
  446.           ban5:=0;
  447.           ban6:=0;
  448.           save.enabled:=false;
  449.           save.ImageIndex:=13;
  450.           end;
  451.         end;
  452.       end{-}
  453.     end;   {1 else}
  454. end;
  455.  
  456.  
  457. procedure TForm1.FormActivate(Sender: TObject);
  458. begin
  459. cb1.items:=screen.fonts;
  460. form1.Show;
  461. form2.hide;
  462. form3.hide;
  463. form1.setfocus;
  464. end;
  465.  
  466. procedure TForm1.saveClick(Sender: TObject);
  467. begin
  468.  if (ban1=1) then
  469.    texto.lines.Savetofile(archivoo)
  470.  else
  471.    begin
  472.    if (ban3=1) then
  473.      texto.lines.Savetofile(archivos)
  474.    else
  475.      begin
  476.      if (savedialog1.Execute) then
  477.        begin
  478.        archivos:=savedialog1.filename;
  479.        ban3:=1;
  480.        ban6:=1;
  481.        ban5:=0;
  482.        texto.lines.Savetofile(savedialog1.filename);
  483.        form1.caption:=savedialog1.filename + ' - Editor de Texto';
  484.        end;
  485.      end;
  486.    end;
  487. end;
  488.  
  489. procedure TForm1.textoChange(Sender: TObject);
  490. begin
  491. if (ban1=1) then     
  492.   begin
  493.   save.enabled:=true;
  494.   save.ImageIndex:=12;
  495.   ban4:=1;
  496.   statusbar1.Panels[2].Text:='Cambio';
  497.   end;
  498.  
  499. if (ban3=1) then
  500.   ban3:=0;
  501.  
  502.  
  503. if (ban2=1) then
  504.   ban5:=1;
  505.  
  506.  
  507. {contamos lineas y caracteres}
  508. statusbar1.panels[1].Text:=inttostr(texto.lines.count)+' Lineas';
  509. statusbar1.panels[0].Text:=inttostr(length(texto.text))+ ' Caracteres';
  510.  
  511. {bloqueamos botones}
  512. if (texto.SelLength>0) then
  513.   begin
  514.   copiar.ImageIndex:=4;
  515.   copiar.enabled:=true;
  516.   cortar.ImageIndex:=6;
  517.   cortar.enabled:=true;
  518.   copiar1.enabled:=true;
  519.   cortar1.enabled:=true;
  520.   end
  521. else
  522.   begin
  523.   copiar.ImageIndex:=5;
  524.   copiar.enabled:=false;
  525.   cortar.ImageIndex:=7;
  526.   cortar.enabled:=false;
  527.   copiar1.enabled:=false;
  528.   cortar1.enabled:=false;
  529.   end;
  530. end;
  531.  
  532. procedure TForm1.ToolButton6Click(Sender: TObject);
  533. begin
  534. if (ban1=1) or (ban3=1) then
  535.   begin
  536.   if (ban1=1) then
  537.     begin
  538.     if (printdialog1.execute) then
  539.       texto.print(archivoo);
  540.     end;
  541.  
  542.   if (ban3=1) then
  543.     begin
  544.     if (printdialog1.execute) then
  545.       texto.print(archivos);
  546.     end;
  547.   end
  548. else
  549.   if (printdialog1.execute) then
  550.     texto.print('Documento.rtf');
  551. end;
  552.  
  553. procedure TForm1.Nuevo1Click(Sender: TObject);
  554. begin
  555.   if (ban1=1) then       {1}
  556.     begin
  557.     if (ban4=1) then       {2}
  558.       begin
  559.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  560.       [mbyes,mbno,mbcancel],0) of
  561.       {NO}
  562.       mrno:
  563.         begin
  564.         texto.Text:='';
  565.         form1.caption:='Documento - Editor de Texto';
  566.         ban2:=1;
  567.         ban1:=0;
  568.         ban3:=0;
  569.         ban4:=0;
  570.         ban5:=0;
  571.         ban6:=0;
  572.         end;
  573.       {YES}
  574.       mryes:
  575.         begin
  576.         texto.lines.Savetofile(archivoo);
  577.         texto.Text:='';
  578.         form1.caption:='Documento - Editor de Texto';
  579.         ban2:=1;
  580.         ban1:=0;
  581.         ban3:=0;
  582.         ban4:=0;
  583.         ban5:=0;
  584.         ban6:=0;
  585.         end;
  586.       end;
  587.      end {2}
  588.     else
  589.       begin
  590.       texto.Text:='';
  591.       form1.caption:='Documento - Editor de Texto';
  592.       ban2:=1;
  593.       ban1:=0;
  594.       ban3:=0;
  595.       ban4:=0;
  596.       ban5:=0;
  597.       ban6:=0;
  598.       end;
  599.     end  {1}
  600.   else  {1 else}
  601.     begin
  602.     if (ban6=0) then
  603.     begin
  604.     if (ban5=1) then      {si cambi贸}
  605.       begin
  606.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  607.       [mbyes,mbno,mbcancel],0) of
  608.         {NO}
  609.         mrno:
  610.           begin
  611.           texto.Text:='';
  612.           form1.caption:='Documento - Editor de Texto';
  613.           ban2:=1;
  614.           ban1:=0;
  615.           ban3:=0;
  616.           ban4:=0;
  617.           ban5:=0;
  618.           ban6:=0;
  619.           end;
  620.         {YES}
  621.         mryes:
  622.           begin
  623.           if (savedialog1.execute) then
  624.             begin
  625.             archivos:=savedialog1.filename;
  626.             texto.lines.Savetofile(savedialog1.filename);
  627.             texto.Text:='';
  628.             form1.caption:='Documento - Editor de Texto';
  629.             ban2:=1;
  630.             ban1:=0;
  631.             ban3:=0;
  632.             ban4:=0;
  633.             ban5:=0;
  634.             ban6:=0;
  635.             end;
  636.           end;
  637.        end;   {case}
  638.       end
  639.     else                  {si no cambi贸}
  640.       begin
  641.       texto.Text:='';
  642.       form1.caption:='Documento - Editor de Texto';
  643.       ban2:=1;
  644.       ban1:=0;
  645.       ban3:=0;
  646.       ban4:=0;
  647.       ban5:=0;
  648.       ban6:=0;
  649.       end;
  650.     end;
  651.  
  652.     if (ban6=1) then     {si se guardo}
  653.       begin  {-}
  654.       if (ban5=1) then    {si cambio}
  655.         begin
  656.         case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  657.         [mbyes,mbno,mbcancel],0) of
  658.           {NO}
  659.           mrno:
  660.             begin
  661.             texto.Text:='';
  662.             form1.caption:='Documento - Editor de Texto';
  663.             ban2:=1;
  664.             ban1:=0;
  665.             ban3:=0;
  666.             ban4:=0;
  667.             ban5:=0;
  668.             ban6:=0;
  669.             end;
  670.           {YES}
  671.           mryes:
  672.             begin
  673.             texto.lines.Savetofile(archivos);
  674.             texto.Text:='';
  675.             form1.caption:='Documento - Editor de Texto';
  676.             ban2:=1;
  677.             ban1:=0;
  678.             ban3:=0;
  679.             ban4:=0;
  680.             ban5:=0;
  681.             ban6:=0;
  682.             end;
  683.          end;   {case}
  684.         end
  685.       else                  {si no cambi贸}
  686.         begin
  687.         texto.Text:='';
  688.         form1.caption:='Documento - Editor de Texto';
  689.         ban2:=1;
  690.         ban1:=0;
  691.         ban3:=0;
  692.         ban4:=0;
  693.         ban5:=0;
  694.         ban6:=0;
  695.         end;
  696.       end{-}
  697.     end;   {1 else}
  698. end;
  699.  
  700. procedure TForm1.Abrir1Click(Sender: TObject);
  701. begin
  702.   if (ban1=1) then       {1}
  703.     begin
  704.     if (ban4=1) then       {2}
  705.       begin
  706.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  707.       [mbyes,mbno,mbcancel],0) of
  708.       {NO}
  709.       mrno:
  710.         begin
  711.         if opendialog1.execute then
  712.           begin
  713.           archivoo:=opendialog1.filename;
  714.           texto.Lines.loadfromfile(opendialog1.filename);
  715.           form1.caption:=opendialog1.filename + ' - Editor de Texto';
  716.           ban1:=1;
  717.           ban2:=0;
  718.           ban4:=0;
  719.           ban3:=0;
  720.           ban5:=0;
  721.           ban6:=0;
  722.           save.enabled:=false;
  723.           save.ImageIndex:=13;
  724.           end;
  725.         end;
  726.       {YES}
  727.       mryes:
  728.         begin
  729.         texto.lines.Savetofile(archivoo);
  730.         if opendialog1.execute then
  731.           begin
  732.           archivoo:=opendialog1.filename;
  733.           texto.Lines.loadfromfile(opendialog1.filename);
  734.           form1.caption:=opendialog1.filename + ' - Editor de Texto';
  735.           ban1:=1;
  736.           ban2:=0;
  737.           ban4:=0;
  738.           ban3:=0;
  739.           ban5:=0;
  740.           ban6:=0;
  741.           save.enabled:=false;
  742.           save.ImageIndex:=13;
  743.           end;
  744.         end;
  745.       end;
  746.      end {2}
  747.     else
  748.       begin
  749.       if opendialog1.execute then
  750.         begin
  751.         archivoo:=opendialog1.filename;
  752.         texto.Lines.loadfromfile(opendialog1.filename);
  753.         form1.caption:=opendialog1.filename + ' - Editor de Texto';
  754.         ban1:=1;
  755.         ban2:=0;
  756.         ban4:=0;
  757.         ban3:=0;
  758.         ban5:=0;
  759.         ban6:=0;
  760.         save.enabled:=false;
  761.         save.ImageIndex:=13;
  762.         end;
  763.       end;
  764.     end  {1}
  765.   else  {1 else}
  766.     begin
  767.     if (ban6=0) then
  768.     begin
  769.     if (ban5=1) then      {si cambi贸}
  770.       begin
  771.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  772.       [mbyes,mbno,mbcancel],0) of
  773.         {NO}
  774.         mrno:
  775.           begin
  776.           if opendialog1.execute then
  777.             begin
  778.             archivoo:=opendialog1.filename;
  779.             texto.Lines.loadfromfile(opendialog1.filename);
  780.             form1.caption:=opendialog1.filename + ' - Editor de Texto';
  781.             ban1:=1;
  782.             ban2:=0;
  783.             ban4:=0;
  784.             ban3:=0;
  785.             ban5:=0;
  786.             ban6:=0;
  787.             save.enabled:=false;
  788.             save.ImageIndex:=13;
  789.             end;
  790.           end;
  791.         {YES}
  792.         mryes:
  793.           begin
  794.           if (savedialog1.execute) then
  795.             begin
  796.             archivos:=savedialog1.filename;
  797.             texto.lines.Savetofile(savedialog1.filename);
  798.             if opendialog1.execute then
  799.               begin
  800.               archivoo:=opendialog1.filename;
  801.               texto.Lines.loadfromfile(opendialog1.filename);
  802.               form1.caption:=opendialog1.filename + ' - Editor de Texto';
  803.               ban1:=1;
  804.               ban2:=0;
  805.               ban4:=0;
  806.               ban3:=0;
  807.               ban5:=0;
  808.               ban6:=0;
  809.               save.enabled:=false;
  810.               save.ImageIndex:=13;
  811.               end;
  812.             end;
  813.           end;
  814.        end;   {case}
  815.       end
  816.     else                  {si no cambi贸}
  817.       begin
  818.       if opendialog1.execute then
  819.         begin
  820.         archivoo:=opendialog1.filename;
  821.         texto.Lines.loadfromfile(opendialog1.filename);
  822.         form1.caption:=opendialog1.filename + ' - Editor de Texto';
  823.         ban1:=1;
  824.         ban2:=0;
  825.         ban4:=0;
  826.         ban3:=0;
  827.         ban5:=0;
  828.         ban6:=0;
  829.         save.enabled:=false;
  830.         save.ImageIndex:=13;
  831.         end;
  832.       end;
  833.     end;
  834.  
  835.     if (ban6=1) then     {si se guardo}
  836.       begin  {-}
  837.       if (ban5=1) then    {si cambio}
  838.         begin
  839.         case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  840.         [mbyes,mbno,mbcancel],0) of
  841.           {NO}
  842.           mrno:
  843.             begin
  844.             if opendialog1.execute then
  845.               begin
  846.               archivoo:=opendialog1.filename;
  847.               texto.Lines.loadfromfile(opendialog1.filename);
  848.               form1.caption:=opendialog1.filename + ' - Editor de Texto';
  849.               ban1:=1;
  850.               ban2:=0;
  851.               ban4:=0;
  852.               ban3:=0;
  853.               ban5:=0;
  854.               ban6:=0;
  855.               save.enabled:=false;
  856.               save.ImageIndex:=13;
  857.               end;
  858.             end;
  859.           {YES}
  860.           mryes:
  861.             begin
  862.             texto.lines.Savetofile(archivos);
  863.             if opendialog1.execute then
  864.               begin
  865.               archivoo:=opendialog1.filename;
  866.               texto.Lines.loadfromfile(opendialog1.filename);
  867.               form1.caption:=opendialog1.filename + ' - Editor de Texto';
  868.               ban1:=1;
  869.               ban2:=0;
  870.               ban4:=0;
  871.               ban3:=0;
  872.               ban5:=0;
  873.               ban6:=0;
  874.               save.enabled:=false;
  875.               save.ImageIndex:=13;
  876.               end;
  877.             end;
  878.          end;   {case}
  879.         end
  880.       else                  {si no cambi贸}
  881.         begin
  882.         if opendialog1.execute then
  883.           begin
  884.           archivoo:=opendialog1.filename;
  885.           texto.Lines.loadfromfile(opendialog1.filename);
  886.           form1.caption:=opendialog1.filename + ' - Editor de Texto';
  887.           ban1:=1;
  888.           ban2:=0;
  889.           ban4:=0;
  890.           ban3:=0;
  891.           ban5:=0;
  892.           ban6:=0;
  893.           save.enabled:=false;
  894.           save.ImageIndex:=13;
  895.           end;
  896.         end;
  897.       end{-}
  898.     end;   {1 else}
  899. end;
  900.  
  901. procedure TForm1.Guardar1Click(Sender: TObject);
  902. begin
  903.  if (ban1=1) then
  904.    texto.lines.Savetofile(archivoo)
  905.  else
  906.    begin
  907.    if (ban3=1) then
  908.      texto.lines.Savetofile(archivos)
  909.    else
  910.      begin
  911.      if (savedialog1.Execute) then
  912.        begin
  913.        archivos:=savedialog1.filename;
  914.        ban3:=1;
  915.        texto.lines.Savetofile(savedialog1.filename);
  916.        form1.caption:=savedialog1.filename + ' - Editor de Texto';
  917.        end;
  918.      end;
  919.    end;
  920. end;
  921.  
  922. procedure TForm1.Salir1Click(Sender: TObject);
  923. begin
  924. if (ban1=1) or (ban3=1) then
  925.   begin
  926.   if (ban1=1) then
  927.     begin
  928.     if (printdialog1.execute) then
  929.       texto.print(archivoo);
  930.     end;
  931.  
  932.   if (ban3=1) then
  933.     begin
  934.     if (printdialog1.execute) then
  935.       texto.print(archivos);
  936.     end;
  937.   end
  938. else
  939.   if (printdialog1.execute) then
  940.     texto.print('Documento.rtf');
  941. end;
  942.  
  943. procedure TForm1.Guardarcomo1Click(Sender: TObject);
  944. begin
  945. if (savedialog1.Execute) then
  946.   begin
  947.   archivos:=savedialog1.filename;
  948.   ban3:=1;
  949.   texto.lines.Savetofile(savedialog1.filename);
  950.   form1.caption:=savedialog1.filename + ' - Editor de Texto';
  951.   end;
  952. end;
  953.  
  954. procedure TForm1.cb1Change(Sender: TObject);
  955. begin
  956.  texto.SelAttributes.Name:=cb1.Text;
  957. end;
  958.  
  959. procedure TForm1.cb2Change(Sender: TObject);
  960. begin
  961. if (cb2.text<>'') then
  962.  texto.SelAttributes.size:=strtoint(cb2.Text);
  963. end;
  964.  
  965. procedure TForm1.ToolButton17Click(Sender: TObject);
  966. begin
  967. if (colordialog1.execute) then
  968.   texto.SelAttributes.Color:=colordialog1.Color;
  969. end;
  970.  
  971. procedure TForm1.ToolButton16Click(Sender: TObject);
  972. begin
  973. if (fontdialog1.execute) then
  974.   begin
  975.   texto.SelAttributes.Name:=fontdialog1.font.Name;
  976.   texto.SelAttributes.size:=fontdialog1.Font.size;
  977.   texto.SelAttributes.style:=fontdialog1.font.style;
  978.   texto.SelAttributes.color:=fontdialog1.font.color;
  979.   end;
  980. end;
  981.  
  982. procedure TForm1.Fuente1Click(Sender: TObject);
  983. begin
  984. if (fontdialog1.execute) then
  985.   begin
  986.   texto.SelAttributes.Name:=fontdialog1.font.Name;
  987.   texto.SelAttributes.size:=fontdialog1.Font.size;
  988.   texto.SelAttributes.style:=fontdialog1.font.style;
  989.   texto.SelAttributes.color:=fontdialog1.font.color;
  990.   end;
  991. end;
  992.  
  993. procedure TForm1.Color1Click(Sender: TObject);
  994. begin
  995. if (colordialog1.execute) then
  996.   texto.SelAttributes.Color:=colordialog1.Color;
  997. end;
  998.  
  999. procedure TForm1.Borrar1Click(Sender: TObject);
  1000. begin
  1001. texto.ClearSelection;
  1002. end;
  1003.  
  1004. procedure TForm1.Seleccionartodo1Click(Sender: TObject);
  1005. begin
  1006. texto.selectall;
  1007. end;
  1008.  
  1009. procedure TForm1.Cortar1Click(Sender: TObject);
  1010. begin
  1011. texto.cuttoclipboard;
  1012. end;
  1013.  
  1014. procedure TForm1.Copiar1Click(Sender: TObject);
  1015. begin
  1016. texto.CopyToClipboard;
  1017. end;
  1018.  
  1019. procedure TForm1.Pegar1Click(Sender: TObject);
  1020. begin
  1021. texto.pastefromclipboard;
  1022. end;
  1023.  
  1024. procedure TForm1.ToolButton12Click(Sender: TObject);
  1025. begin
  1026. texto.pastefromclipboard;
  1027. end;
  1028.  
  1029. procedure TForm1.copiarClick(Sender: TObject);
  1030. begin
  1031. texto.CopyToClipboard;
  1032. end;
  1033.  
  1034. procedure TForm1.cortarClick(Sender: TObject);
  1035. begin
  1036. texto.cuttoclipboard;
  1037. end;
  1038.  
  1039. procedure TForm1.textoMouseUp(Sender: TObject; Button: TMouseButton;
  1040.   Shift: TShiftState; X, Y: Integer);
  1041. begin
  1042. {bloqueamos botones}
  1043. if (texto.SelLength>0) then
  1044.   begin
  1045.   copiar.ImageIndex:=4;
  1046.   copiar.enabled:=true;
  1047.   cortar.ImageIndex:=6;
  1048.   cortar.enabled:=true;
  1049.   copiar1.enabled:=true;
  1050.   cortar1.enabled:=true;
  1051.   end
  1052. else
  1053.   begin
  1054.   copiar.ImageIndex:=5;
  1055.   copiar.enabled:=false;
  1056.   cortar.ImageIndex:=7;
  1057.   cortar.enabled:=false;
  1058.   copiar1.enabled:=false;
  1059.   cortar1.enabled:=false;
  1060.   end;
  1061. end;
  1062.  
  1063. procedure TForm1.ToolButton8Click(Sender: TObject);
  1064. begin
  1065. if (texto.canundo) then
  1066.  texto.Undo;
  1067. end;
  1068.  
  1069. procedure TForm1.ToolButton14Click(Sender: TObject);
  1070. begin
  1071. texto.clearundo;
  1072. end;
  1073.  
  1074. procedure TForm1.Deshacer1Click(Sender: TObject);
  1075. begin
  1076. if (texto.canundo) then
  1077.  texto.Undo;
  1078. end;
  1079.  
  1080. procedure TForm1.Acercadeleditordetexto1Click(Sender: TObject);
  1081. begin
  1082. form2.show;
  1083. end;
  1084.  
  1085. procedure TForm1.Ayuda1Click(Sender: TObject);
  1086. begin
  1087. form3.show;
  1088. end;
  1089.  
  1090. procedure TForm1.ToolButton19Click(Sender: TObject);
  1091. begin
  1092. form3.show;
  1093. end;
  1094.  
  1095. procedure TForm1.ToolButton23Click(Sender: TObject);
  1096. begin
  1097.  texto.Paragraph.Alignment:=tacenter;
  1098. end;
  1099.  
  1100. procedure TForm1.ToolButton22Click(Sender: TObject);
  1101. begin
  1102.  texto.Paragraph.alignment:=taleftjustify;
  1103. end;
  1104.  
  1105. procedure TForm1.ToolButton26Click(Sender: TObject);
  1106. begin
  1107.  texto.paragraph.alignment:=tarightjustify;
  1108. end;
  1109.  
  1110. procedure TForm1.ToolButton10Click(Sender: TObject);
  1111. begin
  1112. for c:=1 to 1 do
  1113. begin
  1114. {1}
  1115.  if (texto.SelAttributes.Style=[fsbold]) then
  1116.    begin
  1117.    texto.SelAttributes.Style:=[];
  1118.    break;
  1119.    end;
  1120. {2}
  1121.  if (texto.SelAttributes.Style=[]) then
  1122.    begin
  1123.    texto.SelAttributes.Style:=[fsbold];
  1124.    break;
  1125.    end;
  1126. {3}
  1127.  if (texto.SelAttributes.Style=[fsbold, fsitalic]) then
  1128.    begin
  1129.    texto.SelAttributes.Style:=[fsitalic];
  1130.    break;
  1131.    end;
  1132. {4}
  1133.  if (texto.SelAttributes.Style=[fsbold, fsunderline]) then
  1134.    begin
  1135.    texto.SelAttributes.Style:=[fsunderline];
  1136.    break;
  1137.    end;
  1138. {5}
  1139.  if (texto.SelAttributes.Style=[fsbold, fsunderline, fsitalic]) then
  1140.    begin
  1141.    texto.SelAttributes.Style:=[fsunderline, fsitalic];
  1142.    break;
  1143.    end;
  1144. {6}
  1145.  if (texto.SelAttributes.Style=[fsunderline, fsitalic]) then
  1146.    begin
  1147.    texto.SelAttributes.Style:=[fsunderline, fsitalic, fsbold];
  1148.    break;
  1149.    end;
  1150. {7}
  1151.  if (texto.SelAttributes.Style=[fsitalic]) then
  1152.    begin
  1153.    texto.SelAttributes.Style:=[fsbold, fsitalic];
  1154.    break;
  1155.    end;
  1156. {8}
  1157.  if (texto.SelAttributes.Style=[fsunderline]) then
  1158.    begin
  1159.    texto.SelAttributes.Style:=[fsbold, fsunderline];
  1160.    break;
  1161.    end;
  1162. end;
  1163. end;
  1164.  
  1165. procedure TForm1.ToolButton11Click(Sender: TObject);
  1166. begin
  1167. for c:=1 to 1 do
  1168. begin
  1169. {1}
  1170.  if (texto.SelAttributes.Style=[fsitalic]) then
  1171.    begin
  1172.    texto.SelAttributes.Style:=[];
  1173.    break;
  1174.    end;
  1175. {2}
  1176.  if (texto.SelAttributes.Style=[]) then
  1177.    begin
  1178.    texto.SelAttributes.Style:=[fsitalic];
  1179.    break;
  1180.    end;
  1181. {3}
  1182.  if (texto.SelAttributes.Style=[fsbold, fsitalic]) then
  1183.    begin
  1184.    texto.SelAttributes.Style:=[fsbold];
  1185.    break;
  1186.    end;
  1187. {4}
  1188.  if (texto.SelAttributes.Style=[fsitalic, fsunderline]) then
  1189.    begin
  1190.    texto.SelAttributes.Style:=[fsunderline];
  1191.    break;
  1192.    end;
  1193. {5}
  1194.  if (texto.SelAttributes.Style=[fsbold, fsunderline, fsitalic]) then
  1195.    begin
  1196.    texto.SelAttributes.Style:=[fsbold, fsunderline];
  1197.    break;
  1198.    end;
  1199. {6}
  1200.  if (texto.SelAttributes.Style=[fsunderline, fsbold]) then
  1201.    begin
  1202.    texto.SelAttributes.Style:=[fsunderline, fsitalic, fsbold];
  1203.    break;
  1204.    end;
  1205. {7}
  1206.  if (texto.SelAttributes.Style=[fsbold]) then
  1207.    begin
  1208.    texto.SelAttributes.Style:=[fsbold, fsitalic];
  1209.    break;
  1210.    end;
  1211. {8}
  1212.  if (texto.SelAttributes.Style=[fsunderline]) then
  1213.    begin
  1214.    texto.SelAttributes.Style:=[fsitalic, fsunderline];
  1215.    break;
  1216.    end;
  1217. end;
  1218. end;
  1219.  
  1220. procedure TForm1.ToolButton20Click(Sender: TObject);
  1221. begin
  1222. for c:=1 to 1 do
  1223. begin
  1224. {1}
  1225.  if (texto.SelAttributes.Style=[fsunderline]) then
  1226.    begin
  1227.    texto.SelAttributes.Style:=[];
  1228.    break;
  1229.    end;
  1230. {2}
  1231.  if (texto.SelAttributes.Style=[]) then
  1232.    begin
  1233.    texto.SelAttributes.Style:=[fsunderline];
  1234.    break;
  1235.    end;
  1236. {3}
  1237.  if (texto.SelAttributes.Style=[fsunderline, fsitalic]) then
  1238.    begin
  1239.    texto.SelAttributes.Style:=[fsitalic];
  1240.    break;
  1241.    end;
  1242. {4}
  1243.  if (texto.SelAttributes.Style=[fsbold, fsunderline]) then
  1244.    begin
  1245.    texto.SelAttributes.Style:=[fsbold];
  1246.    break;
  1247.    end;
  1248. {5}
  1249.  if (texto.SelAttributes.Style=[fsbold, fsunderline, fsitalic]) then
  1250.    begin
  1251.    texto.SelAttributes.Style:=[fsbold, fsitalic];
  1252.    break;
  1253.    end;
  1254. {6}
  1255.  if (texto.SelAttributes.Style=[fsbold, fsitalic]) then
  1256.    begin
  1257.    texto.SelAttributes.Style:=[fsunderline, fsitalic, fsbold];
  1258.    break;
  1259.    end;
  1260. {7}
  1261.  if (texto.SelAttributes.Style=[fsitalic]) then
  1262.    begin
  1263.    texto.SelAttributes.Style:=[fsunderline, fsitalic];
  1264.    break;
  1265.    end;
  1266. {8}
  1267.  if (texto.SelAttributes.Style=[fsbold]) then
  1268.    begin
  1269.    texto.SelAttributes.Style:=[fsbold, fsunderline];
  1270.    break;
  1271.    end;
  1272. end;
  1273. end;
  1274.  
  1275. procedure TForm1.FormCreate(Sender: TObject);
  1276. begin
  1277. ban1:=0;
  1278. ban2:=1;
  1279. ban3:=0;
  1280. ban4:=0;
  1281. ban5:=0;
  1282. ban6:=0;
  1283. texto.SelAttributes.Name:='Tahoma';
  1284. end;
  1285.  
  1286. procedure TForm1.Fondo1Click(Sender: TObject);
  1287. begin
  1288. if (colordialog1.execute) then
  1289.   texto.Color:=colordialog1.Color;
  1290. end;
  1291.  
  1292. procedure TForm1.Buscar1Click(Sender: TObject);
  1293. begin
  1294. finddialog1.Execute;
  1295. end;
  1296.  
  1297. procedure TForm1.Remplazar1Click(Sender: TObject);
  1298. begin
  1299. replacedialog1.Execute;
  1300. ban:=0;
  1301. end;
  1302.  
  1303. procedure TForm1.FindDialog1Find(Sender: TObject);
  1304. begin
  1305. a:=0;
  1306. a:=texto.FindText(finddialog1.FindText, 0, length(texto.text), [stmatchcase]);
  1307. if (a>-1) then
  1308.   begin
  1309.   texto.SetFocus;
  1310.   texto.selstart:=a;
  1311.   texto.sellength:=length(finddialog1.findtext);
  1312.   end
  1313. else
  1314.   messagedlg('No se encontr贸  el texto buscado',mtinformation, [mbok], 0);
  1315. end;
  1316.  
  1317. procedure TForm1.ReplaceDialog1Find(Sender: TObject);
  1318. begin
  1319. a:=0;
  1320. a:=texto.FindText(replacedialog1.FindText, 0, length(texto.text), [stmatchcase]);
  1321. if (a>-1) then
  1322.   begin
  1323.   texto.SetFocus;
  1324.   texto.selstart:=a;
  1325.   texto.sellength:=length(replacedialog1.findtext);
  1326.   end
  1327. else
  1328.   messagedlg('No se encontr贸  el texto buscado',mtinformation, [mbok], 0);
  1329. end;
  1330.  
  1331. procedure TForm1.ReplaceDialog1Replace(Sender: TObject);
  1332. begin
  1333. if (a>-1) and (ban=0)then
  1334.   begin
  1335.   ban:=1;
  1336.   a:=texto.FindText(replacedialog1.FindText, 0, length(texto.text), [stmatchcase]);
  1337.   texto.SetFocus;
  1338.   texto.selstart:=a;
  1339.   texto.sellength:=length(replacedialog1.findtext);
  1340.   texto.SelText:=replacedialog1.ReplaceText;
  1341.   end
  1342. else
  1343.   messagedlg('No se encontr贸 texto para reemplazar',mtinformation, [mbok], 0);
  1344. end;
  1345.  
  1346. procedure TForm1.textoKeyUp(Sender: TObject; var Key: Word;
  1347.   Shift: TShiftState);
  1348. begin
  1349. {bloqueamos botones}
  1350. if (texto.SelLength>0) then
  1351.   begin
  1352.   copiar.ImageIndex:=4;
  1353.   copiar.enabled:=true;
  1354.   cortar.ImageIndex:=6;
  1355.   cortar.enabled:=true;
  1356.   copiar1.enabled:=true;
  1357.   cortar1.enabled:=true;
  1358.   end
  1359. else
  1360.   begin
  1361.   copiar.ImageIndex:=5;
  1362.   copiar.enabled:=false;
  1363.   cortar.ImageIndex:=7;
  1364.   cortar.enabled:=false;
  1365.   copiar1.enabled:=false;
  1366.   cortar1.enabled:=false;
  1367.   end;
  1368. end;
  1369.  
  1370. procedure TForm1.ToolButton1Click(Sender: TObject);
  1371. begin
  1372.   if (ban1=1) then       {1}
  1373.     begin
  1374.     if (ban4=1) then       {2}
  1375.       begin
  1376.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  1377.       [mbyes,mbno,mbcancel],0) of
  1378.       {NO}
  1379.       mrno:
  1380.         begin
  1381.         texto.Text:='';
  1382.         form1.caption:='Documento - Editor de Texto';
  1383.         ban2:=1;
  1384.         ban1:=0;
  1385.         ban3:=0;
  1386.         ban4:=0;
  1387.         ban5:=0;
  1388.         ban6:=0;
  1389.         end;
  1390.       {YES}
  1391.       mryes:
  1392.         begin
  1393.         texto.lines.Savetofile(archivoo);
  1394.         texto.Text:='';
  1395.         form1.caption:='Documento - Editor de Texto';
  1396.         ban2:=1;
  1397.         ban1:=0;
  1398.         ban3:=0;
  1399.         ban4:=0;
  1400.         ban5:=0;
  1401.         ban6:=0;
  1402.         end;
  1403.       end;
  1404.      end {2}
  1405.     else
  1406.       begin
  1407.       texto.Text:='';
  1408.       form1.caption:='Documento - Editor de Texto';
  1409.       ban2:=1;
  1410.       ban1:=0;
  1411.       ban3:=0;
  1412.       ban4:=0;
  1413.       ban5:=0;
  1414.       ban6:=0;
  1415.       end;
  1416.     end  {1}
  1417.   else  {1 else}
  1418.     begin
  1419.     if (ban6=0) then
  1420.     begin
  1421.     if (ban5=1) then      {si cambi贸}
  1422.       begin
  1423.       case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  1424.       [mbyes,mbno,mbcancel],0) of
  1425.         {NO}
  1426.         mrno:
  1427.           begin
  1428.           texto.Text:='';
  1429.           form1.caption:='Documento - Editor de Texto';
  1430.           ban2:=1;
  1431.           ban1:=0;
  1432.           ban3:=0;
  1433.           ban4:=0;
  1434.           ban5:=0;
  1435.           ban6:=0;
  1436.           end;
  1437.         {YES}
  1438.         mryes:
  1439.           begin
  1440.           if (savedialog1.execute) then
  1441.             begin
  1442.             archivos:=savedialog1.filename;
  1443.             texto.lines.Savetofile(savedialog1.filename);
  1444.             texto.Text:='';
  1445.             form1.caption:='Documento - Editor de Texto';
  1446.             ban2:=1;
  1447.             ban1:=0;
  1448.             ban3:=0;
  1449.             ban4:=0;
  1450.             ban5:=0;
  1451.             ban6:=0;
  1452.             end;
  1453.           end;
  1454.        end;   {case}
  1455.       end
  1456.     else                  {si no cambi贸}
  1457.       begin
  1458.       texto.Text:='';
  1459.       form1.caption:='Documento - Editor de Texto';
  1460.       ban2:=1;
  1461.       ban1:=0;
  1462.       ban3:=0;
  1463.       ban4:=0;
  1464.       ban5:=0;
  1465.       ban6:=0;
  1466.       end;
  1467.     end;
  1468.  
  1469.     if (ban6=1) then     {si se guardo}
  1470.       begin  {-}
  1471.       if (ban5=1) then    {si cambio}
  1472.         begin
  1473.         case messagedlg('驴Deseas guardar los cambios?',mtconfirmation,
  1474.         [mbyes,mbno,mbcancel],0) of
  1475.           {NO}
  1476.           mrno:
  1477.             begin
  1478.             texto.Text:='';
  1479.             form1.caption:='Documento - Editor de Texto';
  1480.             ban2:=1;
  1481.             ban1:=0;
  1482.             ban3:=0;
  1483.             ban4:=0;
  1484.             ban5:=0;
  1485.             ban6:=0;
  1486.             end;
  1487.           {YES}
  1488.           mryes:
  1489.             begin
  1490.             texto.lines.Savetofile(archivos);
  1491.             texto.Text:='';
  1492.             form1.caption:='Documento - Editor de Texto';
  1493.             ban2:=1;
  1494.             ban1:=0;
  1495.             ban3:=0;
  1496.             ban4:=0;
  1497.             ban5:=0;
  1498.             ban6:=0;
  1499.             end;
  1500.          end;   {case}
  1501.         end
  1502.       else                  {si no cambi贸}
  1503.         begin
  1504.         texto.Text:='';
  1505.         form1.caption:='Documento - Editor de Texto';
  1506.         ban2:=1;
  1507.         ban1:=0;
  1508.         ban3:=0;
  1509.         ban4:=0;
  1510.         ban5:=0;
  1511.         ban6:=0;
  1512.         end;
  1513.       end{-}
  1514.     end;   {1 else}
  1515. end;
  1516.  
  1517. end.

Form2

DELPHI:
  1. unit Unit2;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, jpeg, ExtCtrls;
  8.  
  9. type
  10.   TForm2 = class(TForm)
  11.     Image1: TImage;
  12.     Label1: TLabel;
  13.     Label2: TLabel;
  14.     Label3: TLabel;
  15.     Label4: TLabel;
  16.     Button1: TButton;
  17.     procedure Button1Click(Sender: TObject);
  18.   private
  19.     { Private declarations }
  20.   public
  21.     { Public declarations }
  22.   end;
  23.  
  24. var
  25.   Form2: TForm2;
  26.  
  27. implementation
  28.  
  29. uses Unit1, Unit3;
  30.  
  31. {$R *.dfm}
  32.  
  33. procedure TForm2.Button1Click(Sender: TObject);
  34. begin
  35. form2.Hide;
  36. end;
  37.  
  38. end.

Form3

DELPHI:
  1. unit Unit3;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls;
  8.  
  9. type
  10.   TForm3 = class(TForm)
  11.     Label1: TLabel;
  12.     Label2: TLabel;
  13.     Label3: TLabel;
  14.     Label4: TLabel;
  15.     Label5: TLabel;
  16.     Label6: TLabel;
  17.     Label7: TLabel;
  18.     Label8: TLabel;
  19.     Button1: TButton;
  20.     procedure Button1Click(Sender: TObject);
  21.   private
  22.     { Private declarations }
  23.   public
  24.     { Public declarations }
  25.   end;
  26.  
  27. var
  28.   Form3: TForm3;
  29.  
  30. implementation
  31.  
  32. uses Unit2, Unit1;
  33.  
  34. {$R *.dfm}
  35.  
  36. procedure TForm3.Button1Click(Sender: TObject);
  37. begin
  38. form3.Hide;
  39. end;
  40.  
  41. end.

Como veras son 3 unidades (3 formularios) y muchas lineas de codigo jeje.. Lo que mas me cost贸 fue la parte de "abrir", "guardar" y "Nuevo" ya que esta validado... Funciona casi igual al Bloc de Notas de Windows, pero desarrollado en Delphi :P

Aqu铆 te dejo los archivos para que los descargues (ya que son varios, entre imagenes y demas cosas) Espero y te sirva de algo :)

Archivos