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

InsertMenu с картинкой   Найти похожие ветки 

 
roughneck   (2006-05-17 14:56) [0]

Добавляю Item в меню с помощью Insertmenu. Как к новому элементу меню добавить картинку (слева 16х16)? Спасибо.


 
Handle   (2006-05-17 15:51) [1]

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, Shellapi, ShlObj;
type
 TIconType = (itSmall, itLarge);
type
 TForm1 = class(TForm)
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

function GetIcon(const FileName: string; const IconType: TIconType = itSmall):
 TIcon;
var
 FileInfo: TShFileInfo;
 ImageList: TImageList;
 IT: DWORD;
begin
 IT := SHGFI_SMALLICON;
 Result := TIcon.Create;
 ImageList := TImageList.Create(nil);
 if (IconType = itLarge) then
 begin
   IT := SHGFI_LARGEICON;
   ImageList.Height := 32;
   ImageList.Width := 32;
 end;
 FillChar(FileInfo, Sizeof(FileInfo), #0);
 ImageList.ShareImages := true;
 ImageList.Handle := SHGetFileInfo(
   PChar(FileName),
   SFGAO_SHARE,
   FileInfo,
   sizeof(FileInfo),
   IT or SHGFI_SYSICONINDEX
   );
 ImageList.GetIcon(FileInfo.iIcon, Result);
 ImageList.Free;
end;

procedure ...
begin
ImageList1.AddIcon(GetIcon("filename"));
Item.ImageIndex:= 0 ;
end;

end.


 
begin...end ©   (2006-05-17 17:16) [2]

Вызывать InsertMenuItem, использовать флаг MIIM_BITMAP. Радоваться.



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

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



Память: 0.45 MB
Время: 0.032 c
2-1156510613
Der Nechk@ssoff
2006-08-25 16:56
2006.09.17
Определить тип файла


1-1155106048
-=Germe$=-
2006-08-09 10:47
2006.09.17
Где ошибка? Подскажите....


8-1141248230
ShAB_v2.0
2006-03-02 00:23
2006.09.17
Как усреднить цвета до одного цвета?


2-1156749497
GeneralMotors
2006-08-28 11:18
2006.09.17
Пробудить комп


15-1156191797
Piter
2006-08-22 00:23
2006.09.17
Методы работы антивирусных почтовых сканеров




   Наверх