Autor Beitrag
Rool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: Sa 08.03.03 18:01 
Ich habe jetzt folgendes:

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
procedure TfraPlaylist.lvwListCustomDraw(Sender: TCustomListView;
  const ARect: TRect; var DefaultDraw: Boolean);
var
  ScrollY, y: Integer;
  Bitmap: TBitmap;
  NodeHeight: Integer;
begin
    if (Sender as TListView).Items.Count = 0 then
      ScrollY := 0
    else begin
      with (Sender as TListView).Items[0].DisplayRect(drBounds) do
        NodeHeight := Bottom - Top+1;
      ScrollY := GetScrollPos(Sender.Handle, SB_VERT)*(NodeHeight);
    end;
    with Sender.Canvas do begin
      Brush.Color := clWhite;
      FillRect(ARect);
      Bitmap:=TBitmap.Create;
      Bitmap.LoadFromResourceName(HInstance,'BMP_LIST');
      y := -ScrollY;
      while (y < ARect.Bottom) do begin
        Draw(0, y, Bitmap);
        inc(y, Bitmap.Height);
      end;
    end;
    Bitmap.Free;
    DefaultDraw := True;
end;

procedure TfraPlaylist.lvwListAdvancedCustomDrawItem(
  Sender: TCustomListView; Item: TListItem; State: TCustomDrawState;
  Stage: TCustomDrawStage; var DefaultDraw: Boolean);
var
  NodeHeight: Integer;
  Rect: TRect;
begin
  Rect := Item.DisplayRect(drBounds);
  DefaultDraw := True;
  if Stage = cdPrePaint then begin
    NodeHeight := (Rect.Bottom-Rect.Top+1);
      with Sender.Canvas do begin
        Brush.Color := $002D5132;
        Brush.Style:=bsSolid;
        if not (cdsSelected in State) then begin
          Font.Color:=$202020;
          SetBkMode(Sender.Canvas.Handle, TRANSPARENT);
          TextOut(NodeHeight, Rect.top, Item.Caption)
        end else begin
          Font.Color:=clSilver;
          SetBkMode(Sender.Canvas.Handle, OPAQUE);
          TextOut(NodeHeight, Rect.top, Item.Caption)
        end;
      end;
      //DefaultDraw := False;                                                  <<Muss true sein, damit die SubItems auch noch gezeichnet werden...
  end;
end;

procedure TfraPlaylist.lvwListAdvancedCustomDrawSubItem(
  Sender: TCustomListView; Item: TListItem; SubItem: Integer;
  State: TCustomDrawState; Stage: TCustomDrawStage;
  var DefaultDraw: Boolean);
var
  NodeHeight: Integer;
  Rect: TRect;
  sl, i: Integer;                                                           //subitem-breite
begin
  sl:=0;
  Rect := Item.DisplayRect(drBounds);
  for i:= 0 to SubItem-1 do
      sl:=sl+Sender.Column[i].Width;
  //ShowMessage(inttostr(sl));
  DefaultDraw := True;
  if Stage = cdPrePaint then begin
    NodeHeight := (Rect.Bottom-Rect.Top+1);
      with Sender.Canvas do begin
        Brush.Color := $002D5132;
        Brush.Style:=bsSolid;
        if not (cdsSelected in State) then begin
          Font.Color:=$202020;
          SetBkMode(Sender.Canvas.Handle, TRANSPARENT);
          TextOut(NodeHeight+sl, Rect.top, Item.SubItems[SubItem-1])
        end else begin
          Font.Color:=clSilver;
          SetBkMode(Sender.Canvas.Handle, OPAQUE);
          TextOut(NodeHeight+sl, Rect.top, Item.SubItems[SubItem-1])
        end;
      end;
      DefaultDraw := False;
  end;
end;




In dem Code wird ein Bild aus ner Ressource geladen und als Hintergrund in einem Listview gemalt.
Wenn ich DefaultDraw := False setze (in der 2. Prozedur), dann werden die SubItems nicht gezeichnet (3. Proz. wird gar nicht aufgerufen). Lasse ich es auf true, übermalt delphi meine einträge nach der 2. Prozedur nochmal, und zwar mit deckendem Hintergrund. D.h. mein Bild geht verloren.

Was kann man da machen??? Ich bin öllig ratlos!

_________________
MFG Rool
Böser Borstel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154



BeitragVerfasst: Do 13.03.03 13:18 
Titel: Was?
was passiert wenn du erst di einträge machst und dann das bild ladest
CenBells
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1547

Win 7
Delphi XE5 Pro
BeitragVerfasst: Do 13.03.03 16:33 
hast du mal versuch canvas.brush oder canvas.pen zu setzten?

Gruß
Leo *g*
Rool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: Do 13.03.03 16:58 
An Böser Borstel:
Dann werden die Einträge vom Bild übermalt!

Zu CenBells:
Hab ich schon versucht...

_________________
MFG Rool
Böser Borstel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 154



BeitragVerfasst: Fr 14.03.03 07:34 
Titel: tja
dann geht meine lösung auch nicht, würde mich aber drüber freuen wenn jemand dieses problem noch lösen kann!
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Fr 14.03.03 16:51 
Hallo Rool!

Ich kann dein Problem nicht ganz nachvollziehen: Hab dein Beispiel gerade gebprüft und bei mir sah es eigentlich ganz ordentlich aus.
Beweis: user defined image!

Gruß wulfskin!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
Rool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: Sa 15.03.03 12:20 
Titel: cool
wie komisch. sieht ja echt ganz gut aus...
hast du irgendwelche bestimmten propertys gesetzt/geändert?

_________________
MFG Rool