unit sravFal;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, sSkinProvider, sSkinManager, StdCtrls, Buttons, ComCtrls,
ExtCtrls, Gauges;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
sSkinManager1: TsSkinManager;
sSkinProvider1: TsSkinProvider;
RichEdit1: TRichEdit;
RichEdit2: TRichEdit;
OpenDialog1: TOpenDialog;
BitBtn6: TBitBtn;
StatusBar1: TStatusBar;
BitBtn5: TBitBtn;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
ProgressBar1: TProgressBar;
Label5: TLabel;
Label6: TLabel;
procedure FormResize(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1; i:Integer; a: byte;
implementation
{$R *.dfm}
procedure TForm1.FormResize(Sender: TObject);
begin
RichEdit1.Width:= Form1.Width div 2 - 10;
RichEdit2.Left:= RichEdit1.Width + 8;
RichEdit2.Width:= RichEdit1.Width;
StatusBar1.Panels[0].Width:= Form1.Width - 160;
ProgressBar1.Width:= StatusBar1.Panels[0].Width - 8;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
RichEdit1.Perform(EM_LIMITTEXT, $7FFFFFF0, 0);
If not OpenDialog1.Execute then exit;
RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
ProgressBar1.Max:= RichEdit1.Lines.Count;
Label1.Caption:= IntToStr(RichEdit1.Lines.Count);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
RichEdit2.Perform(EM_LIMITTEXT, $7FFFFFF0, 0);
RichEdit2.Font.Color:= clBlack;
RichEdit2.DefAttributes.Color:= clBlack;
If not OpenDialog1.Execute then exit;
RichEdit2.Lines.LoadFromFile(OpenDialog1.FileName);
Label6.Caption:= IntToStr(RichEdit2.Lines.Count);
end;
procedure TForm1.BitBtn6Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
var j: Word; l: Integer; s, s1, ch1, ch2: String;
begin
with Richedit1 do
begin
Selstart := perform(EM_LINEINDEX, 0, 0);
SelLength:= Length(RichEdit1.Lines.Strings[0]);
perform(EM_SCROLLCARET, 0, 0);
end;
with Richedit2 do
begin
Selstart := perform(EM_LINEINDEX, 0, 0);
SelLength:= Length(RichEdit2.Lines.Strings[0]);
perform(EM_SCROLLCARET, 0, 0);
end;
StatusBar1.Panels[1].Text:='Идёт сравнение, ждите';
i:= 0;
l:= RichEdit1.Lines.Count;
Label1.Caption:= IntToStr(l);
Label6.Caption:= IntToStr(RichEdit2.Lines.Count);
s:= RichEdit1.Lines.Strings[i];
s1:= RichEdit2.Lines.Strings[i];
while s = s1 do
begin
If l = i then
begin
If a < 2 then
StatusBar1.Panels[1].Text:='Файлы одинаковы'
else
If a = 2 then
StatusBar1.Panels[1].Text:='Файлы отличаются';
Windows.Beep(500, 500);
with Richedit1 do
begin
Selstart := perform(EM_LINEINDEX, i, 0);
SelLength:= Length(RichEdit1.Lines.Strings[i]);
perform(EM_SCROLLCARET, 0, 0);
end;
with Richedit2 do
begin
Selstart := perform(EM_LINEINDEX, i, 0);
SelLength:= Length(RichEdit2.Lines.Strings[i]);
perform(EM_SCROLLCARET, 0, 0);
end;
exit;
end;
Inc(i);
s:= RichEdit1.Lines.Strings[i];
s1:= RichEdit2.Lines.Strings[i];
ProgressBar1.Position:= i;
Label2.Caption:= IntToStr(i);
Application.ProcessMessages;
end;
For j:=0 to Length(RichEdit1.Lines.Strings[i]) do
begin
ch1:= Copy(s, j, 1);
ch2:= Copy(s1, j, 1);
If ch1 <> ch2 then
begin
RichEdit2.SelStart := RichEdit2.Perform(EM_LINEINDEX, i, 0) + (j - 1);
Break;
end;
end;
with Richedit1 do
begin
Selstart := perform(EM_LINEINDEX, i, 0);
SelLength:= Length(RichEdit1.Lines.Strings[i]){ - j};
SelAttributes.Color:=clBlue;
perform(EM_SCROLLCARET, 0, 0);
end;
with Richedit2 do
begin
SelLength:= Length(RichEdit2.Lines.Strings[i]) - j + 1;
SelAttributes.Color:=clRed;
perform(EM_SCROLLCARET, 0, 0);
end;
StatusBar1.Panels[1].Text:='Строка отличается';
Windows.Beep(500, 250);
a:= 2;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with ProgressBar1 do
begin
Parent := StatusBar1;
Top := 5;
Left := 4;
Height := StatusBar1.Height - 8;
Width := StatusBar1.Panels[0].Width - 8;
end;
PostMessage(ProgressBar1.Handle, $0409, 0, clGreen);
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
var j: Word; l: Integer; s, s1, ch1, ch2: String;
begin
StatusBar1.Panels[1].Text:='Идёт сравнение, ждите';
l:= RichEdit1.Lines.Count;
Label1.Caption:= IntToStr(l);
Label6.Caption:= IntToStr(RichEdit2.Lines.Count);
Inc(i);
s:= RichEdit1.Lines.Strings[i];
s1:= RichEdit2.Lines.Strings[i];
l:= RichEdit1.Lines.Count;
while s = s1 do
begin
If l <= i then
begin
If a < 2 then
StatusBar1.Panels[1].Text:='Файлы одинаковы'
else
If a = 2 then
StatusBar1.Panels[1].Text:='Файлы отличаются';
Windows.Beep(500, 500);
with Richedit1 do
begin
Selstart := perform(EM_LINEINDEX, i, 0);
SelLength:= Length(RichEdit1.Lines.Strings[i]);
perform(EM_SCROLLCARET, 0, 0);
end;
with Richedit2 do
begin
Selstart := perform(EM_LINEINDEX, i, 0);
SelLength:= Length(RichEdit2.Lines.Strings[i]);
perform(EM_SCROLLCARET, 0, 0);
end;
exit;
end;
Inc(i);
s:= RichEdit1.Lines.Strings[i];
s1:= RichEdit2.Lines.Strings[i];
ProgressBar1.Position:= i;
Label2.Caption:= IntToStr(i);
Application.ProcessMessages;
end;
For j:=0 to Length(RichEdit1.Lines.Strings[i]) do
begin
ch1:= Copy(s, j, 1);
ch2:= Copy(s1, j, 1);
If ch1 <> ch2 then
begin
RichEdit2.SelStart := RichEdit2.Perform(EM_LINEINDEX, i, 0) + (j - 1);
Break;
end;
end;
with Richedit1 do
begin
Selstart := perform(EM_LINEINDEX, i, 0);
SelLength:= Length(RichEdit1.Lines.Strings[i]){ - j};
SelAttributes.Color:=clBlue;
perform(EM_SCROLLCARET, 0, 0);
end;
with Richedit2 do
begin
SelLength:= Length(RichEdit2.Lines.Strings[i]) - j;
SelAttributes.Color:=clRed;
perform(EM_SCROLLCARET, 0, 0);
end;
StatusBar1.Panels[1].Text:='Строка отличается';
Windows.Beep(500, 250);
a:= 2;
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
begin
i:= RichEdit1.Lines.Count;
ProgressBar1.Position:= ProgressBar1.Max;
end;
end.
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.