Вниз
Скачать: CL | DM;

как впихнуть в ImageList иконку нестандартного размера   Найти похожие ветки 

 
webpauk ©   (2012-06-18 12:42) [0]

На форме есть ImageList (Width = 48, Height = 48)
Пытаюсь:

MyIcon:=TIcon.Create;
MyIcon.Width:=48;
MyIcon.Height:=48;
ImageList.AddIcon(MyIcon);

происходит ошибка, т.к. при добавлении иконки в AddIcon проверяется её размеры:

function TCustomImageList.AddIcon(Image: TIcon): Integer;
begin
 if Image = nil then
   Result := Add(nil, nil)
 else
 begin
   CheckImage(Image);
   Result := ImageList_AddIcon(Handle, Image.Handle);
 end;
 Change;
end;

procedure TCustomImageList.CheckImage(Image: TGraphic);
begin
 if Image <> nil then
   with Image do
     if (Height < FHeight) or (Width < FWidth) then
       raise EInvalidOperation.Create(SInvalidImageSize);
end;


Как обойти ограничение? Ведь вручную иконка впихивается!!!


 
brother ©   (2012-06-18 12:52) [1]

перекрыть CheckImage?


 
webpauk ©   (2012-06-18 13:11) [2]

Нашел:

function ImageList_ReplaceIcon(ImageList: THandle; Index: Integer; Icon: hIcon): Integer; stdcall; external "comctl32.dll" name "ImageList_ReplaceIcon";

procedure MyAddIconPrc;
begin
  ImageList_ReplaceIcon(ImageList.Handle, -1, MyIcon.Handle);
end;



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.05 c
2-1343646644
Pcrepair
2012-07-30 15:10
2013.03.22
Программа начинает есть память


2-1340259411
Теркин
2012-06-21 10:16
2013.03.22
Сохранение объектов в базе данных


15-1341211017
KilkennyCat
2012-07-02 10:36
2013.03.22
Понедельничная задачка :)


2-1329076090
dis12345
2012-02-12 23:48
2013.03.22
checkbox в stringgrid


15-1335417549
Palladin
2012-04-26 09:19
2013.03.22
EurekaLog и юнит ExceptionLog




   Наверх