0
Aşağıdaki delphi projesini incelermisin. Neresinde yanlış var?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, strutils, Menus, ImgList, Buttons;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Timer1: TTimer;
ListBox2: TListBox;
Edit1: TEdit;
Label1: TLabel;
Button2: TButton;
Label2: TLabel;
PopupMenu1: TPopupMenu;
Listeyitemizle1: TMenuItem;
Button3: TButton;
OpenDialog1: TOpenDialog;
Label3: TLabel;
BukarakterinKonumakaytlarnlistele1: TMenuItem;
ImageList1: TImageList;
ListBox3: TListBox;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Button4: TButton;
Edit2: TEdit;
BalloonHint1: TBalloonHint;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Listeyitemizle1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure BukarakterinKonumakaytlarnlistele1Click(Sender: TObject);
procedure ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
procedure Button4Click(Sender: TObject);
procedure Edit2KeyPress(Sender: TObject; var Key: Char);
procedure Edit1Change(Sender: TObject);
procedure ListBox1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
const
htCaptionBtn = htSizeLast + 1;
{$R *.dfm}
procedure TForm1.BukarakterinKonumakaytlarnlistele1Click(Sender: TObject);
var
i,a:integer;
begin
listbox2.Items. Clear;
for I := 0 to Listbox1.count - 1 do
begin
a:=AnsiPos(edit1.Text+' :',listbox1.Items[i]);
if a<>0 then
begin
listbox2.Items.Add(listbox1.Items[i]);
end;
end;
listbox1.Clear;
listbox1.Items:=listbox2.Items;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
satir:integer;
yil,ay,gun:Word;
sonuc:integer;
a:string;
begin
decodedate(now,yil,ay,gun);
listbox1.Clear;
listbox2.Clear;
listbox3.Clear;
deletefile('copyfile-'+'ChattingLog-'+inttostr(yil)+'-'+inttostr(ay)+'-'+inttostr(gun)+'.txt');
copyfile(pwidechar('ChattingLog-'+inttostr(yil)+'-'+inttostr(ay)+'-'+inttostr(gun)+'.txt'),pwidechar('copyfile-'+'ChattingLog-'+inttostr(yil)+'-'+inttostr(ay)+'-'+inttostr(gun)+'.txt'),true);
FileSetAttr('copyfile-'+'ChattingLog-'+inttostr(yil)+'-'+inttostr(ay)+'-'+inttostr(gun)+'.txt',faHidden);
listbox2.Items. LoadFromFile('copyfile-'+'ChattingLog-'+inttostr(yil)+'-'+inttostr(ay)+'-'+inttostr(gun)+'.txt');
if listbox2.Count<=65536 then
begin
for satir := listbox2.Count-1 downto 0 do
begin
sonuc:=ansipos(']',listbox2.Items[satir]);
a:=ansirightstr(listbox2.Items[satir],length(listbox2.Items[satir])-(sonuc+2));
listbox1.Items.Add(ansiuppercase(a));
listbox3.Items.Add(ansimidstr(listbox2.Items[satir],(ansipos('=',listbox2.Items[satir]))+1,sonuc-(ansipos('=',listbox2.Items[satir]))-1));
end;
end
else
begin
for satir := 65536 downto 0 do
begin
sonuc:=ansipos(']',listbox2.Items[satir]);
a:=ansirightstr(listbox2.Items[satir],length(listbox2.Items[satir])-(sonuc+2));
listbox1.Items.Add(ansiuppercase(a));
listbox3.Items.Add(ansimidstr(listbox2.Items[satir],(ansipos('=',listbox2.Items[satir]))+1,sonuc-(ansipos('=',listbox2.Items[satir]))-1));
end;
end;
form1.Caption:='ChattingLog-'+inttostr(yil)+'-'+inttostr(ay)+'-'+inttostr(gun)+'.txt';
end;
procedure TForm1.Button2Click(Sender: TObject);
var
a:integer;
begin
if button2.Caption='Otomatik güncelle' then
begin
try
a:=strtoint(inputbox('Yenileme süresi girin','Saniye','4'));
except
showmessage('Lütfen sayısal içerik girin'+#13#10+'Girilen değer en fazla 120 olabilir');
end;
if a>120 then
begin
showmessage('Lütfen yenileme süresini 2 dakikadan fazla yapmayın');
end
else
begin
timer1.Interval:=a*1000;
timer1.Enabled:=true;
button2.Caption:='Güncellemeyi durdur';
label2.Caption:=inttostr(a)+' saniyede bir'+#13#10+'Güncellenecek';
end;
end
else
begin
timer1.Enabled:=false;
button2.Caption:='Otomatik güncelle';
label2.Caption:=;
end
end;
procedure TForm1.Button3Click(Sender: TObject);
var
satir:integer;
sonuc:integer;
a:string;
begin
opendialog1.Execute;
if opendialog1.FileName<> then
begin
listbox2.Items. LoadFromFile(opendialog1.FileName);
listbox1.Items. Clear;
if listbox2.Count<=65536 then
begin
for satir := listbox2.Count-1 downto 0 do
begin
sonuc:=ansipos(']',listbox2.Items[satir]);
a:=ansirightstr(listbox2.Items[satir],length(listbox2.Items[satir])-(sonuc+2));
listbox1.Items.Add(ansiuppercase(a));
end;
end
else
begin
for satir := 65536 downto 0 do
begin
sonuc:=ansipos(']',listbox2.Items[satir]);
a:=ansirightstr(listbox2.Items[satir],length(listbox2.Items[satir])-(sonuc+2));
listbox1.Items.Add(ansiuppercase(a));
end;
end;
form1.Caption:=opendialog1.FileName;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
qmc:integer;
begin
if edit2.text<>'' then
begin
button1.Click;
listbox2.Clear;
for qmc := 0 to Listbox1.Count - 1 do
begin
if ansipos(ansiuppercase(edit2.text),listbox1.Items[qmc])<>0 then
listbox2.Items.Add(listbox1.Items[qmc])
end;
listbox1.Items:=listbox2.Items;
end;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
edit1.Hint:=edit1.Text;
end;
procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char);
begin
if key = #13 then
button4.Click;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
label4.Hint:=label4.Caption+' yazıları beyaz görünür.';
label5.Hint:=label5.Caption+' yazıları kırmızı görünür.';
label6.Hint:=label6.Caption+' yazıları yeşil görünür.';
label7.Hint:=label7.Caption+' yazıları gri görünür.';
label8.Hint:=label8.Caption+' yazıları açık mavi görünür.';
label9.Hint:=label9.Caption+' yazıları koyu mavi görünür.';
label10.Hint:=label10.Caption+' yazıları sarı görünür.';
button1.Hint:='Bugüne ait chatlogu listele';
button2.Hint:='Belirlenen sürede listeyi güncelle';
button3.Hint:='Eski kayıtları kontrol et';
button4.Hint:='Mevcut listede Arama yap'+#13#10+'Büyük harf-Küçük harf duyarlıdır';
listbox2.Hide;
listbox3.Hide;
end;
procedure TForm1.FormDestroy(Sender: TObject);
var
yil,ay,gun:word;
begin
decodedate(now,yil,ay,gun);
deletefile('copyfile-'+'ChattingLog-'+inttostr(yil)+'-'+inttostr(ay)+'-'+inttostr(gun)+'.txt');
end;
procedure TForm1.ListBox1Click(Sender: TObject);
var
satir, isimno:longword;
begin
try
satir:=listbox1.ItemIndex;
if listbox1.Items[satir]<>'' then
begin
if listbox1.ItemIndex<=listbox1.Count then
isimno:=ansipos(' ',listbox1.Items[satir]);
edit1.text:=ansileftstr(listbox1.Items[satir],isimno-1);
end;
except
end;
end;
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState);
var
index1:longword;
begin
index1:=strtoint(listbox3.Items[index]);
begin
With ( Control As TListBox ).Canvas Do
Begin
Case index1 Of
1: Font. Color := clwhite;
3: Font. Color := $00988516;
5: Font. Color := $003C97F2;
6: Font. Color := cllime;
14: Font. Color := $00E6CFB9;
15: Font. Color := $00E4CF8F;
17: Font. Color := clyellow;
End;
FillRect(Rect);
TextOut(Rect. Left, Rect.Top, ( Control As TListBox
).Items[Index]);
End;
end;
end;
procedure TForm1.Listeyitemizle1Click(Sender: TObject);
begin
listbox1.Items. Clear;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
listbox1.Items. Clear;
button1.Click;
end;
end.
Tümünü Göster