Delphi-PRAXiS
Seite 1 von 3  1 23      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi TListView.OnDrawItem (https://www.delphipraxis.net/155982-tlistview-ondrawitem.html)

WojTec 15. Nov 2010 19:22

Delphi-Version: 2010

TListView.OnDrawItem
 
I wanted make list with recent files. I also wanted make grey these items, that match file not exists (click File-->Reopen-->Properties in Delphi to see what I want to do). This is what I have:

Delphi-Quellcode:
begin
  with lvRecentFiles, lvRecentFiles.Canvas do
  begin
    if FileExists(Item.Caption) then
      Pen.Color := clBlack
    else
      Pen.Color := clGrayText
    ;

    TextOut(Rect.Left + 2, Rect.Top + 2, Item.Caption);
  end;
end;
I want just grey text if file not exists. Any help with this? :(

mkinzler 15. Nov 2010 19:34

AW: TListView.OnDrawItem
 
Delphi-Quellcode:
if FileExists(Item.Caption) then
      Font.Color := clBlack
    else
      Font.Color := clGrayText;

WojTec 15. Nov 2010 19:42

Re: TListView.OnDrawItem
 
Oh, why I didn't think about this :D

Delphi-Quellcode:
begin
  with lvRecentFiles, lvRecentFiles.Canvas do
  begin
    if FileExists(Item.Caption) then
      Font.Color := clBlack
    else
      Font.Color := clGrayText
    ;

    //TextOut(Rect.Left + 2, Rect.Top + 2, Item.Caption);

    R := Classes.Rect(Rect.Left + 6, Rect.Top + 3, Rect.Right, Rect.Bottom - 2);
    S := Item.Caption;
    TextRect(R, S, [tfEndEllipsis]);
  end;
end;
There is grey, but can't be selected as when OwnerDraw is False (in system style). In Delphi can be. Any idea?

mkinzler 15. Nov 2010 19:45

AW: TListView.OnDrawItem
 
You have to evaluate the state

Luckie 15. Nov 2010 19:48

AW: TListView.OnDrawItem
 
The item gets selected, but you don't see it because it is your responsiblity to give the user visual feedback if you draw the items yourself.

WojTec 15. Nov 2010 19:53

Re: TListView.OnDrawItem
 
So, how I can draw it in current Windows's style?

Luckie 15. Nov 2010 19:55

AW: TListView.OnDrawItem
 
Markus gave you the answer.

WojTec 15. Nov 2010 20:05

Re: TListView.OnDrawItem
 
Yes, but how about in current system style. For example in XP there is solid color, but on Vista+ there is gradiented. I want to just grey text, all other should be "original". Are you understand what I mean ;)

mkinzler 15. Nov 2010 20:07

AW: TListView.OnDrawItem
 
Call the standard Draw-Routine after you set the new Color

WojTec 15. Nov 2010 20:10

Re: TListView.OnDrawItem
 
What you mean? I'm not pro in owner drawing :( Could you give me an example?


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:29 Uhr.
Seite 1 von 3  1 23      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz