Вниз
Скачать: 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
3-1152875840
drashka
2006-07-14 15:17
2006.09.17
Как лучше реализовать поиск?


2-1156910249
demonn1112
2006-08-30 07:57
2006.09.17
treeview


15-1156859319
Chort
2006-08-29 17:48
2006.09.17
MathCad против Delphi


2-1156703273
Leyhont
2006-08-27 22:27
2006.09.17
Параметры в SQL запросе


2-1156608865
хм...
2006-08-26 20:14
2006.09.17
Edit




   Наверх