Autor Beitrag
Addy88
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP, Win 7

BeitragVerfasst: Di 19.01.10 22:17 
Hallo liebe Gemeinde,

ich hab mal ne Frage die wahrscheinlich schnell und einfach beantwortet ist.
Und zwar möchte ich die ListViewCustomDrawItem Procedure aus einer anderen aufrufen, leider weiß ich nicht wirklich welche Parameter ich übergeben muss.

Sieht bei mir momentan so aus:
ausblenden Delphi-Quelltext
1:
Form1.ListView1CustomDrawItem(nil,nil,nil,true);					
Allerdings funktioniert das so nicht (wer hätte das gedacht :D )
Bekomme immer diese Fehlermeldung beim compilieren:

Inkompatible Typen: 'TCustomDrawState' und 'Pointer'

Wäre Klasse wenn mir jemand sagen könnte welche Parameter ich übergeben muss.

Vielen Dank im voraus.

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Di 19.01.10 23:04 
Gegenfrage: Wozu?
Die Prozedur wird doch automatisch aufgerufen, wenn es Zeit ist, das Ding neu zu malen.

_________________
PROGRAMMER: A device for converting coffee into software.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 19.01.10 23:18 
user profile iconAddy88 hat folgendes geschrieben Zum zitierten Posting springen:
Und zwar möchte ich die ListViewCustomDrawItem Procedure aus einer anderen aufrufen, leider weiß ich nicht wirklich welche Parameter ich übergeben muss.
Lagere einfach den Code, den du mehrfach benutzen willst, in eine gemeinsam benutzte Prozedur auf mit eigenen Parametern. Dann kannst du diese sowohl von ListViewCustomDrawItem als auch von woanders aufrufen. ;-)
Addy88 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP, Win 7

BeitragVerfasst: Di 19.01.10 23:24 
Hmm klingt einleuchtend aber ich hab eine Prozedur "aktualisieren" welche den Inhalt des ListViews nach Änderungen in einer Datenbank aktualisiert.

Jetzt wollte ich in dieser procedure eben die Customdraw procedure aufrufen um falls ein bestimmter wert gesetzt ist diese aktuelle Zeile eingefärbt wird.
Oder ist das direkt der falsche Ansatz?

Sieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure aktualisieren;
Form1.nichtda:=Form4.SQLQuery1.FieldByName('nichtda').AsString; //verliehen oder nicht
Form1.zaehler:=0//gibt die aktuelle Zeile der Listview an

Form1.ListView1CustomDrawItem(Form1.ListView1,Form1.zaehler,nil,true);

procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
if nichtda = 'true' then
    begin
      if item.Index=Form1.zaehler THEN  // färbe Zeile
        begin
        Sender.Canvas.Brush.Color := clRed; // roten "Pinsel" für den Hintergrund
        Sender.Canvas.Font.Color := clBlack; // Schrift-Farbe schwarz
        DefaultDraw := True; // item normal zeichnen
        end;
    end;
end;

Wenn ich da einen denkfehler habe, sag mir bitte wo der liegt und wie ich es anders machen kann.

Danke

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 19.01.10 23:46 
Wenn du den Inhalt neuzeichnen lassen willst, dann musst du nur Invalidate aufrufen. ;-)
Addy88 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP, Win 7

BeitragVerfasst: Mi 20.01.10 09:38 
Äh und jetzt noch mal für mich, wie genau ruf ich invalidate auf?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 20.01.10 10:45 
Wie meinst du das? :nixweiss:
ausblenden Delphi-Quelltext
1:
YourListView.Invalidate;					
Addy88 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win XP, Win 7

BeitragVerfasst: Mi 20.01.10 10:48 
OK danke. Da hätte ich auch alleine drauf kommen können -.-
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19314
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 20.01.10 10:51 
Wobei das die gesamte ListView neu zeichnet. Für einzelne Items gibt es ListView_RedrawItems oder YourListView.Items[YourItem].Update (wobei ich letzteres nie ausprobiert habe).