Thema: Delphi TListView.OnDrawItem

Einzelnen Beitrag anzeigen

Namenloser

Registriert seit: 7. Jun 2006
Ort: Karlsruhe
3.724 Beiträge
 
FreePascal / Lazarus
 
#17

AW: TListView.OnDrawItem

  Alt 16. Nov 2010, 17:43
You could use MSDN-Library durchsuchenDrawThemedBackground from the UxTheme api. Here's a quick example:
Delphi-Quellcode:
uses UxTheme;

TMyForm = class(TForm)
private
  Theme: hTheme;
end;

procedure TMyForm.FormCreate(Sender: TObject);
begin
  Theme := OpenThemeData(0, 'ListView');
end;

procedure TMyForm.FormDestroy(Sender: TObject);
begin
  CloseThemeData(Theme);
end;

procedure TMyForm.ListViewCustomDraw(...);
var
  StateId: Integer;
begin
  StateId := LIS_SELECTED; // LIS_SELECTEDNOTFOCUS // LIS_NORMAL
  DrawThemeBackground(
    Theme,
    ListView.Canvas.Handle,
    LVP_LISTITEM,
    StateId,
    Rect,
    nil
  );
  { Other drawing code... }
end;
But if you do this, be careful to check if Themes are available or else your program will not work on older systems.

[edit]
In order to see any difference, you have to execute the SetWindowTheme-code from above first (before you acquire the theme handle). Or you could replace 'ListView' with 'Explorer::ListView' . But the former version is preferable.
[/edit]

Geändert von Namenloser (16. Nov 2010 um 17:47 Uhr)
  Mit Zitat antworten Zitat