| 1 |
|
3 |
//---------------------------------------------------------------------------
|
| 2 |
|
|
#include <vcl\vcl.h>
|
| 3 |
|
|
#include <string.h>
|
| 4 |
|
|
#pragma hdrstop
|
| 5 |
|
|
|
| 6 |
|
|
#include "edition.h"
|
| 7 |
|
|
#include "fenetre.h"
|
| 8 |
|
|
//---------------------------------------------------------------------------
|
| 9 |
|
|
#pragma resource "*.dfm"
|
| 10 |
|
|
TEditeur *Editeur;
|
| 11 |
|
|
//---------------------------------------------------------------------------
|
| 12 |
|
|
__fastcall TEditeur::TEditeur(TComponent* Owner)
|
| 13 |
|
|
: TForm(Owner)
|
| 14 |
|
|
{
|
| 15 |
|
|
}
|
| 16 |
|
|
//---------------------------------------------------------------------------
|
| 17 |
|
|
void __fastcall TEditeur::FormShow(TObject *Sender)
|
| 18 |
|
|
{
|
| 19 |
|
|
char mess[255],mess2[255];
|
| 20 |
|
|
|
| 21 |
|
|
OpenDialog1->InitialDir=Fenp->dir_defaut;
|
| 22 |
|
|
if (OpenDialog1->Execute()==true)
|
| 23 |
|
|
{
|
| 24 |
|
|
strcpy(mess,OpenDialog1->FileName.c_str());
|
| 25 |
|
|
strcpy(mess2,(strrchr(mess,'\\')+1));
|
| 26 |
|
|
Caption=mess2;
|
| 27 |
|
|
RichEdit1->Clear();
|
| 28 |
|
|
RichEdit1->Lines->LoadFromFile(OpenDialog1->FileName);
|
| 29 |
|
|
}
|
| 30 |
|
|
RichEdit1->Font->Color=clWindowText;
|
| 31 |
|
|
Left=Fenp->Left+45;
|
| 32 |
|
|
Top=Fenp->Top+66;
|
| 33 |
|
|
}
|
| 34 |
|
|
//---------------------------------------------------------------------------
|
| 35 |
|
|
void __fastcall TEditeur::Fermer1Click(TObject *Sender)
|
| 36 |
|
|
{
|
| 37 |
|
|
Close();
|
| 38 |
|
|
}
|
| 39 |
|
|
//---------------------------------------------------------------------------
|
| 40 |
|
|
void __fastcall TEditeur::Ouvrir1Click(TObject *Sender)
|
| 41 |
|
|
{
|
| 42 |
|
|
char mess[255],mess2[255];
|
| 43 |
|
|
|
| 44 |
|
|
StatusBar1->Panels->Items[2]->Text="Lecture";
|
| 45 |
|
|
OpenDialog1->InitialDir="";
|
| 46 |
|
|
if (OpenDialog1->Execute()==true)
|
| 47 |
|
|
{
|
| 48 |
|
|
strcpy(mess,OpenDialog1->FileName.c_str());
|
| 49 |
|
|
strcpy(mess2,(strrchr(mess,'\\')+1));
|
| 50 |
|
|
Caption=mess2;
|
| 51 |
|
|
RichEdit1->Clear();
|
| 52 |
|
|
RichEdit1->Lines->LoadFromFile(OpenDialog1->FileName);
|
| 53 |
|
|
}
|
| 54 |
|
|
RichEdit1->Font->Color=clWindowText;
|
| 55 |
|
|
Left=Fenp->Left+45;
|
| 56 |
|
|
Top=Fenp->Top+66;
|
| 57 |
|
|
StatusBar1->Panels->Items[2]->Text="Edition";
|
| 58 |
|
|
}
|
| 59 |
|
|
//---------------------------------------------------------------------------
|
| 60 |
|
|
void __fastcall TEditeur::Lecture1Click(TObject *Sender)
|
| 61 |
|
|
{
|
| 62 |
|
|
Lecture1->Checked=true;
|
| 63 |
|
|
Ecriture1->Checked=false;
|
| 64 |
|
|
Enregistrer1->Enabled=false;
|
| 65 |
|
|
RichEdit1->ReadOnly=true;
|
| 66 |
|
|
StatusBar1->Panels->Items[0]->Text="Lecture";
|
| 67 |
|
|
}
|
| 68 |
|
|
//---------------------------------------------------------------------------
|
| 69 |
|
|
void __fastcall TEditeur::Ecriture1Click(TObject *Sender)
|
| 70 |
|
|
{
|
| 71 |
|
|
Lecture1->Checked=false;
|
| 72 |
|
|
Ecriture1->Checked=true;
|
| 73 |
|
|
Enregistrer1->Enabled=true;
|
| 74 |
|
|
RichEdit1->ReadOnly=false;
|
| 75 |
|
|
StatusBar1->Panels->Items[0]->Text="Ecriture";
|
| 76 |
|
|
}
|
| 77 |
|
|
//---------------------------------------------------------------------------
|
| 78 |
|
|
void __fastcall TEditeur::Enregistrer1Click(TObject *Sender)
|
| 79 |
|
|
{
|
| 80 |
|
|
char mess[255];
|
| 81 |
|
|
FILE *out;
|
| 82 |
|
|
int i;
|
| 83 |
|
|
|
| 84 |
|
|
StatusBar1->Panels->Items[2]->Text="Enregistrement";
|
| 85 |
|
|
SaveDialog1->FileName=OpenDialog1->FileName;
|
| 86 |
|
|
if (SaveDialog1->Execute()==true)
|
| 87 |
|
|
{
|
| 88 |
|
|
strcpy(mess,SaveDialog1->FileName.c_str());
|
| 89 |
|
|
Caption=mess;
|
| 90 |
|
|
out=fopen(SaveDialog1->FileName.c_str(),"wt");
|
| 91 |
|
|
for (i=0;i<RichEdit1->Lines->Count;i++)
|
| 92 |
|
|
fprintf(out,"%s\n",RichEdit1->Lines->Strings[i].c_str());
|
| 93 |
|
|
fclose(out);
|
| 94 |
|
|
}
|
| 95 |
|
|
StatusBar1->Panels->Items[2]->Text="Edition";
|
| 96 |
|
|
}
|
| 97 |
|
|
//---------------------------------------------------------------------------
|
| 98 |
|
|
void __fastcall TEditeur::FormClose(TObject *Sender, TCloseAction &Action)
|
| 99 |
|
|
{
|
| 100 |
|
|
Action=caFree;
|
| 101 |
|
|
}
|
| 102 |
|
|
//---------------------------------------------------------------------------
|
| 103 |
|
|
void __fastcall TEditeur::StatusBar1Resize(TObject *Sender)
|
| 104 |
|
|
{
|
| 105 |
|
|
StatusBar1->Panels->Items[0]->Width=Editeur->ClientWidth/4;
|
| 106 |
|
|
StatusBar1->Panels->Items[1]->Width=Editeur->ClientWidth/4;
|
| 107 |
|
|
StatusBar1->Panels->Items[2]->Width=Editeur->ClientWidth/2;
|
| 108 |
|
|
}
|
| 109 |
|
|
//---------------------------------------------------------------------------
|
| 110 |
|
|
void __fastcall TEditeur::FormCreate(TObject *Sender)
|
| 111 |
|
|
{
|
| 112 |
|
|
StatusBar1->Panels->Items[0]->Width=Editeur->ClientWidth/4;
|
| 113 |
|
|
StatusBar1->Panels->Items[1]->Width=Editeur->ClientWidth/4;
|
| 114 |
|
|
StatusBar1->Panels->Items[2]->Width=Editeur->ClientWidth/2;
|
| 115 |
|
|
}
|
| 116 |
|
|
//---------------------------------------------------------------------------
|