Also, erstmal hier der Code:
So klappts prima zur Laufzeit!
Vorraussetzung:
ToolBar mit genügend ToolButtons.
ImageList1 enthält die normalen Bitmaps,
ImageList2 für den Hover-Effekt.
Beiden ImageList müssen leer sein.
Delphi-Quellcode:
uses
XPMan, CommCtrl, Consts;
{...}
procedure ConvertTo32BitImageList(
const ImageList: TImageList);
const Mask:
array[Boolean]
of Longint = (0, ILC_MASK);
var TempList: TImageList;
begin
if Assigned(ImageList)
then
begin
TempList := TImageList.Create(
nil);
try
TempList.Assign(ImageList);
with ImageList
do
begin
Handle := ImageList_Create(Width, Height, ILC_COLOR32
or Mask[Masked], 0, AllocBy);
if not HandleAllocated
then
raise EInvalidOperation.Create(SInvalidImageList);
end;
Imagelist.AddImages(TempList);
finally
FreeAndNil(TempList);
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var b: TBitmap; h: HModule;
begin
ConvertTo32BitImageList(ImageList1);
ConvertTo32BitImageList(ImageList2);
b := TBitmap.Create;
try
h := LoadLibrary('
shell32.dll');
if h <> 0
then
try
{ normal }
b.LoadFromResourceID(h, 216);
ImageList1.Add(b, b);
ToolBar1.Images := ImageList1;
{ hover }
b.LoadFromResourceID(h, 217);
ImageList2.Add(b, b);
ToolBar1.HotImages := ImageList2;
finally
FreeLibrary(h);
end;
finally
b.Free;
end;
ToolBar1.Flat := True;
// für den Hover-Effekt
end;