Computer Games Forum

Go Back   Computer Games Forum > Tech > Software

Notices

Reply
 
LinkBack Thread Tools
Old 24-07-2001, 04:45   #1 (permalink)
SGi
Registered User
 
Join Date: Aug 2000
Location: Ploiesti
Delphi 5 + TListView + WinMe

pana acum am stat sa imi dau seama ce are urmatoarea bucata de cod... nu am reusit.
Ok, pentru cine vrea sa ma ajute,si are Delphi 5 in care sa zicem ca se pricepe sa faca un program, here's the problem:

se da un TListView (din tab-ul System). Se adauga 6 coloane (columns), apoi un buton. La OnClick pe buton scrieti urmatorul cod:
procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
for i:=0 to 100 do
begin
lv.Items.Add.Caption:='ASX';
lv.Items.Item[i].SubItems.Add('Altceva1');
lv.Items.Item[i].SubItems.Add('Altceva2');
lv.Items.Item[i].SubItems.Add('Altceva3');
lv.Items.Item[i].SubItems.Add(inttostr(random(100)));
lv.Items.Item[i].SubItems.Add(inttostr(random(100)));
end;
end;

lv este lista TlistView setata in mod vsReport si cu OwnerDraw False.
Ok, apoi la lista la eventul OnCustomDrawItem urmatorul cod:

procedure TForm1.lvCustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var idx3,idx4:integer;
begin
DefaultDraw:=True;
idx3:=StrToInt(item.SubItems.Strings[3]);
idx4:=StrToInt(item.SubItems.Strings[4]);

if idx4=idx3 then
begin
lv.Canvas.Font.Color:=RGb(0,215,0);
lv.canvas.Font.Style:=[fsBold];
end;
if idx4<idx3 then
begin
lv.Canvas.Font.Color:=clNavy;
lv.canvas.Font.Style:=[fsBold];
end;
if idx4=0 then
begin
lv.Canvas.Font.Color:=clRed;
lv.canvas.Font.Style:=[];
end;
end;

acum se ruleaza programul si se apasa butonul. Apoi incepeti si faceti scroll la lista. La un moment dat Item-urile or sa inceapa sa nu mai fie scrise cu [Bold]. Deschideti acum Notepad-ul si dati About. Uitati-va la System Resources. Daca sunt peste 60% atunci e ok totul, daca nu (si asta mai mult k sigur), faceti-ma sa inteleg unde si ce am gresit. Totusi eu nu cred ca am gresit ceva, cred ca este de la Win Me, din cauza asta daca aveti 98 spuneti-mi cum se comporta. Pe Win2000 sp2 am inteles ca nu face asa.
Ma seaca chestia asta de cateva zile, asa ca orice ajutor este binevenit.
 
SGi is online now    Reply With Quote
Advertisment
Reply

  Computer Games Forum > Tech > Software

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +2. The time now is 20:13.


This site is copyrighted ©1997 - 2009, Computer Games Online SRL