unit Unit1;
{$DEFINE WINDOWSXPSTYLE}
{$IFDEF WINDOWSXPSTYLE}
{$R WinXP.Res}
{$ENDIF}
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;
type
TMyListView =
class(TListView)
protected
procedure WndProc(
var Message: TMessage);
override;
end;
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
ListView1: TMyListView;
IL: TImageList;
procedure LVBGImage;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses
ComObj, CommCtrl, ShellAPI;
{$R *.dfm}
// const in CommCtrl:
// LVBKIF_SOURCE_NONE = 0; // Nix
// LVBKIF_SOURCE_HBITMAP = 1; // HBitmap source
// LVBKIF_SOURCE_URL = 2; // Path to Bitmap
// LVBKIF_SOURCE_MASK = 3; // BitmapMaske ?
// LVBKIF_STYLE_NORMAL = 0; // ???
// LVBKIF_STYLE_TILE = 16; // Gekachelt
// LVBKIF_STYLE_MASK = 16; // ???
procedure TMyListView.WndProc(
var Message: TMessage);
begin
if Message.Msg = WM_ERASEBKGND
then
DefaultHandler(
Message)
else
inherited WndProc(
Message);
end;
procedure TForm1.LVBGImage;
var
LVBKImage : TLVBKIMAGE;
begin
FillChar(LVBKImage, SizeOf(LVBKImage), 0);
LVBKImage.ulFlags := LVBKIF_SOURCE_URL
or LVBKIF_STYLE_TILE;
LVBKImage.pszImage := PChar('
c:\windows\angler.bmp');
// Bmp, Gif, Png, Jpg 's
LVBKImage.hbm := 0;
LVBKImage.xOffsetPercent := 0;
LVBKImage.yOffsetPercent := 0;
ListView_SetBkImage(ListView1.Handle, @LVBKImage);
//ListView_SetBKColor(ListView1.Handle, CLR_NONE);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Byte;
Icon : TIcon;
begin
// Icon & Imagelist bauen...
Icon := TIcon.Create;
Icon.Handle := ExtractIcon(HInstance, '
SHELL32.DLL', 6);
IL := TImageList.Create(Self);
IL.Width := 32;
IL.Height := 32;
IL.AddIcon(Icon);
Icon.Free;
// Listview erstellen
ListView1 := TMyListView.Create(Self);
// Listview füllen
with ListView1
do
begin
Parent := Self;
Left := 5;
Top := 5;
Width := 250;
Height := 200;
With ListView1.Columns.Add
do
Caption := '
First';
With ListView1.Columns.Add
do
Caption := '
Sub';
ViewStyle := vsReport;
//ViewStyle := vsIcon;
LargeImages :=
IL;
end;
LVBGImage;
for i := 0
to 24
do
with ListView1.Items.Add
do
begin
Caption := format('
%s%x',[Chr(Ord('
A') + i), i]);
ImageIndex := 0;
SubItems.Add(format('
%5.5d', [i]));
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
ListView1.Free;
IL.Free;
end;
end.