Вниз
Скачать: 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.44 MB
Время: 0.031 c
15-1155462028
tButton
2006-08-13 13:40
2006.09.17
две проблемы


15-1156585648
vlad-mal
2006-08-26 13:47
2006.09.17
Есть ли возможность читать форум через NNTP?


2-1156659780
andy_hs
2006-08-27 10:23
2006.09.17
сделать программу невидимой (службой)


15-1156750303
ANB
2006-08-28 11:31
2006.09.17
Чье оружие круче ?


3-1152312861
S@shka
2006-07-08 02:54
2006.09.17
Можно ли оценить размер БД




   Наверх