![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
InsertMenu с картинкой
roughneck © (2006-05-17 14:56:00)Добавляю Item в меню с помощью Insertmenu. Как к новому элементу меню добавить картинку (слева 16х16)? Спасибо.
begin...end (2006-05-17 17:16:00) [1]Вызывать InsertMenu Item, использовать флаг MIIM_BITMAP. Радоваться.
Handle (2006-05-17 15:51:00) [2]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.