AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

TListView.OnDrawItem

Ein Thema von WojTec · begonnen am 15. Nov 2010 · letzter Beitrag vom 17. Nov 2010
Antwort Antwort
Seite 1 von 3  1 23      
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

TListView.OnDrawItem

  Alt 15. Nov 2010, 19:22
Delphi-Version: 2010
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?

Geändert von WojTec (15. Nov 2010 um 19:24 Uhr)
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: TListView.OnDrawItem

  Alt 15. Nov 2010, 19:34
Delphi-Quellcode:
if FileExists(Item.Caption) then
      Font.Color := clBlack
    else
      Font.Color := clGrayText;
Markus Kinzler
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: TListView.OnDrawItem

  Alt 15. Nov 2010, 19:42
Oh, why I didn't think about this

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?
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#4

AW: TListView.OnDrawItem

  Alt 15. Nov 2010, 19:45
You have to evaluate the state
Markus Kinzler
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#5

AW: TListView.OnDrawItem

  Alt 15. Nov 2010, 19:48
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.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#6

Re: TListView.OnDrawItem

  Alt 15. Nov 2010, 19:53
So, how I can draw it in current Windows's style?
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#7

AW: TListView.OnDrawItem

  Alt 15. Nov 2010, 19:55
Markus gave you the answer.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#8

Re: TListView.OnDrawItem

  Alt 15. Nov 2010, 20:05
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
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#9

AW: TListView.OnDrawItem

  Alt 15. Nov 2010, 20:07
Call the standard Draw-Routine after you set the new Color
Markus Kinzler
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#10

Re: TListView.OnDrawItem

  Alt 15. Nov 2010, 20:10
What you mean? I'm not pro in owner drawing Could you give me an example?
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 3  1 23      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:19 Uhr.
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