La fiche principale, le code associé dans la unit
La deuxième fiche, le code associé dans la unit
Exécuter
le programme
La fiche principale du projet :
Le code de la Unit fiche principale :
unit Uedit2;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, Menus, StdCtrls, ExtCtrls, Buttons, Uaide2;
type
TForm1 = class(TForm)
TextEditeur: TMemo;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
MainMenu1: TMainMenu;
Fichier1: TMenuItem;
Nouveau1: TMenuItem;
Ouvrir1: TMenuItem;
Enregistrersous1: TMenuItem;
N1: TMenuItem;
Quitter1: TMenuItem;
Edition1: TMenuItem;
Couper1: TMenuItem;
Copier1: TMenuItem;
Coller1: TMenuItem;
Options1: TMenuItem;
Polices1: TMenuItem;
Couleurs1: TMenuItem;
Standard1: TMenuItem;
FontDialog1: TFontDialog;
ColorDialog1: TColorDialog;
PanelAffiche: TPanel;
N2: TMenuItem;
Barremenus1: TMenuItem;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
SpeedButton5: TSpeedButton;
SpeedButton6: TSpeedButton;
SpeedButton7: TSpeedButton;
SpeedButton8: TSpeedButton;
Apropos1: TMenuItem;
procedure Quitter1Click(Sender: TObject);
procedure Ouvrir1Click(Sender: TObject);
procedure Enregistrersous1Click(Sender: TObject);
procedure Couper1Click(Sender: TObject);
procedure Copier1Click(Sender: TObject);
procedure Coller1Click(Sender: TObject);
procedure Nouveau1Click(Sender: TObject);
procedure Polices1Click(Sender: TObject);
procedure TextEditeurChange(Sender: TObject);
procedure Barremenus1Click(Sender: TObject);
procedure Couleurs1Click(Sender: TObject);
procedure Standard1Click(Sender: TObject);
procedure Apropos1Click(Sender: TObject);
private
{ Private declarations
}
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Quitter1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Ouvrir1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
Enregistrersous1.enabled:=true;
TextEditeur.Lines.LoadFromFile(OpenDialog1.FileName);
Uaide2.AboutBox.Etatsave.text:='NON'
end
end;
procedure TForm1.Enregistrersous1Click(Sender: TObject);
begin
if SaveDialog1.Execute then
begin
Enregistrersous1.enabled:=false;
TextEditeur.Lines.SaveToFile( SaveDialog1.FileName );
Uaide2.AboutBox.Etatsave.text:='OUI'
end
end;
procedure TForm1.Couper1Click(Sender: TObject);
begin
TextEditeur.CutToClipboard;
end;
procedure TForm1.Copier1Click(Sender: TObject);
begin
TextEditeur.CopyToClipboard;
end;
procedure TForm1.Coller1Click(Sender: TObject);
begin
TextEditeur.PasteFromClipboard;
end;
procedure TForm1.Nouveau1Click(Sender: TObject);
begin
TextEditeur.text:='';
Enregistrersous1.enabled:=true;
Uaide2.AboutBox.Etatsave.text:='NON'
end;
procedure TForm1.Polices1Click(Sender: TObject);
begin
if FontDialog1.Execute then
begin
TextEditeur.Font:= FontDialog1.Font;
Uaide2.AboutBox.PoliceCar.text:=TextEditeur.Font.name;
with Uaide2.AboutBox , TextEditeur.Font do
begin
if fsBold in Style then StyleCar.text:='Gras';
if fsItalic in Style then StyleCar.text:='Italique';
if fsUnderline in Style then StyleCar.text:='Souligné';
if fsStrikeout in Style then StyleCar.text:='Barré';
if Style=[] then StyleCar.text:='Standard'
end;
Uaide2.AboutBox.TailleCar.text:=inttostr(TextEditeur.Font.Size)
end
end;
procedure TForm1.TextEditeurChange(Sender: TObject);
{Dès qu'un changement intervient sauvegarde
possible}
begin
Enregistrersous1.enabled:=true;
end;
procedure TForm1.Barremenus1Click(Sender: TObject);
begin
if Barremenus1.tag=1 then
begin
Barremenus1.tag:=0;
Barremenus1.Caption:='Masquer barre menus';
PanelAffiche.visible:=true;
Uaide2.AboutBox.Barremenu.text:='visible'
end
else
begin
Barremenus1.tag:=1;
Barremenus1.Caption:='Voir barre menus';
PanelAffiche.visible:=false;
Uaide2.AboutBox.Barremenu.text:='Non visible'
end
end;
procedure TForm1.Couleurs1Click(Sender: TObject);
begin
if ColorDialog1.Execute then
begin
TextEditeur.Color:= ColorDialog1.Color;
end
end;
procedure TForm1.Standard1Click(Sender: TObject);
begin
TextEditeur.Color:=clWindow;
TextEditeur.Font.Name:='system';
TextEditeur.Font.Style:=[fsBold];
TextEditeur.Font.Size:=10;
Uaide2.AboutBox.PoliceCar.text:='system';
Uaide2.AboutBox.StyleCar.text:='Gras';
Uaide2.AboutBox.TailleCar.text:='10'
end;
procedure TForm1.Apropos1Click(Sender: TObject);
begin
if Apropos1.tag=0 then
begin
Apropos1.tag:=1;
Form1.Left:=4;
Form1.Top:=78;
Form1.Width:=387;
Uaide2.AboutBox.Left:=392;
Uaide2.AboutBox.Top:=78;
Uaide2.AboutBox.Show
end
else
begin
Apropos1.tag:=0;
Uaide2.AboutBox.Hide
end
end;
end.
Remonter
Une deuxième fiche dans le projet :
Le code de la Unit associée à la deuxième fiche :
unit Uaide2;
interface
uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls,
StdCtrls,
Buttons, ExtCtrls;
type
TAboutBox = class(TForm)
Panel1: TPanel;
ProgramIcon: TImage;
ProductName: TLabel;
Version: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
PoliceCar: TEdit;
StyleCar: TEdit;
TailleCar: TEdit;
Etatsave: TEdit;
Barremenu: TEdit;
Label6: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
AboutBox: TAboutBox;
implementation
{$R *.DFM}
procedure TAboutBox.FormCreate(Sender: TObject);
begin
ProductName.Caption:='Micro-Editeur de texte';
Version.Caption:='Version 2.0';
AboutBox.Left:=392;
AboutBox.Top:=78
end;
end.
Remonter