Bueno, como me voy a madrugar ya os pongo el código que tengo hasta ahora.
·Program:
Código Delphi
[-]program edittxt;
uses
Forms,
editortextos in 'editortextos.pas' ,
guardar in 'guardar.pas' ;
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
·Unidad prinicipal:
Código Delphi
[-]unit editortextos;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Menus, ToolWin;
type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
SaveDialog1: TSaveDialog;
MainMenu1: TMainMenu;
N1: TMenuItem;
Guardar1: TMenuItem;
PopupMenu1: TPopupMenu;
Copiar1: TMenuItem;
Pegar1: TMenuItem;
N2: TMenuItem;
Exit1: TMenuItem;
Salir1: TMenuItem;
ToolBar1: TToolBar;
Memo1: TMemo;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
procedure FormResize(Sender: TObject; var NewWidth, NewHeight: Integer;
var Resize: Boolean);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Guardar1Click(Sender: TObject);
procedure Copiar1Click(Sender: TObject);
procedure Pegar1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure Salir1Click(Sender: TObject);
procedure Memo1Change(Sender: TObject);
private
public
end;
var
Form1: TForm1;
cambiado: boolean;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.FormResize(Sender: TObject; var NewWidth,
NewHeight: Integer; var Resize: Boolean);
begin
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if cambiado = true then
Form2.Show;
Form2.BringToFront;
exit;
end;
procedure TForm1.Guardar1Click(Sender: TObject);
begin
begin
if SaveDialog1.Execute then
memo1.Lines.SaveToFile(SaveDialog1.FileName);
cambiado:=false
end;
end;
procedure TForm1.Copiar1Click(Sender: TObject);
begin
memo1.CopyToClipboard;
end;
procedure TForm1.Pegar1Click(Sender: TObject);
begin
memo1.PasteFromClipboard;
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
Halt;
end;
procedure TForm1.Salir1Click(Sender: TObject);
begin
halt;
end;
procedure TForm1.Memo1Change(Sender: TObject);
begin
cambiado:=true
end;
end.
·Unidad de guardado de seguridad:
Código Delphi
[-]unit guardar;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
public
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
if SaveDialog1.Execute then begin
memo1.Lines.SaveToFile(SaveDialog1.FileName);
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
halt;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
Form1.Show;
Form1.BringToFront;
end;
end.
·Unidad gráfica principal.
Código Delphi
[-]object Form1: TForm1
Left = 349
Top = 306
Width = 676
Height = 426
Caption = 'Editor de texto'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Menu = MainMenu1
OldCreateOrder = False
OnCanResize = FormResize
OnClose = FormClose
PixelsPerInch = 96
TextHeight = 13
object StatusBar1: TStatusBar
Left = 0
Top = 394
Width = 651
Height = 19
Panels = <
item
Width = 50
end
item
Text = 'Escribe arriba lo que desees.'
Width = 50
end>
end
object ToolBar1: TToolBar
Left = 0
Top = 0
Width = 651
Height = 25
ButtonWidth = 25
Caption = 'ToolBar1'
TabOrder = 1
object ToolButton1: TToolButton
Left = 0
Top = 2
Width = 8
Caption = 'ToolButton1'
Style = tbsSeparator
end
object ToolButton2: TToolButton
Left = 8
Top = 2
Caption = 'ToolButton2'
end
end
object Memo1: TMemo
Left = 0
Top = 25
Width = 651
Height = 353
Align = alTop
Lines.Strings = (
'')
PopupMenu = PopupMenu1
TabOrder = 2
OnChange = Memo1Change
end
object SaveDialog1: TSaveDialog
DefaultExt = 'txt'
FileName = 'prueba'
Filter = 'Archivos de texto|*.txt|Scripts|*.scp'
Left = 32
Top = 40
end
object MainMenu1: TMainMenu
Left = 64
Top = 40
object N1: TMenuItem
Caption = 'Archivo'
Default = True
object Guardar1: TMenuItem
Caption = 'Guardar'
OnClick = Guardar1Click
end
object Salir1: TMenuItem
Caption = 'Salir'
OnClick = Salir1Click
end
end
end
object PopupMenu1: TPopupMenu
Left = 96
Top = 40
object Copiar1: TMenuItem
Caption = 'Copiar'
OnClick = Copiar1Click
end
object Pegar1: TMenuItem
Caption = 'Pegar'
OnClick = Pegar1Click
end
object N2: TMenuItem
Caption = '________'
end
object Exit1: TMenuItem
Caption = 'Salir'
OnClick = Exit1Click
end
end
end
·Unidad gráfica de guardado de seguridad:
Código Delphi
[-]object Form2: TForm2
Left = 534
Top = 286
Width = 245
Height = 139
Caption = '¡Atencion!'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 56
Top = 16
Width = 124
Height = 13
Caption = '¿Deseas guardar el texto?'
end
object Button1: TButton
Left = 40
Top = 40
Width = 75
Height = 25
Caption = 'Si'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 120
Top = 40
Width = 75
Height = 25
Caption = 'No'
TabOrder = 1
OnClick = Button2Click
end
object Button3: TButton
Left = 80
Top = 72
Width = 75
Height = 25
Caption = 'Cancelar'
TabOrder = 2
OnClick = Button3Click
end
end