
27.09.2009, 21:47
|
 |
Начинающий
|
|
Регистрация: 01.10.2008
Сообщения: 138
Версия Delphi: 7
Репутация: 21
|
|
после обдумывания вышло так:
Код:
procedure TMainForm.CreateMenu(Data: TListBox);
procedure AddIcon(Data: TListBox);
var
ID_Icon: TIcon;
i, Index: word;
begin
Icon_Small.Clear;
ID_Icon := TIcon.Create;
if Data.Items.Count > 0 then
begin
for i := 0 to Data.Count - 1 do
begin
ID_Icon.Handle := ExtractAssociatedIcon(Hinstance, PChar(Data.Items.Strings[i]), Index);
Icon_Small.AddIcon(ID_Icon);
end;
end;
end;
var
i, Index: Word;
Item: TMenuItem;
ID_Icon: TIcon;
begin
if FileExists(GetWinDir +'\'+ ConfigFile) and (Data.Items.Count > 0) then
begin
AddIcon(Data);
with ListPopupMenu.Items do
begin
AddIcon(Data);
while Count > 0 do Items[0].Free;
if Data.Count > 0 then
begin
for i := 0 to Data.Count - 1 do
begin
ID_Icon := TIcon.Create;
ID_Icon.Handle := ExtractAssociatedIcon(Hinstance, PChar(Data.Items.Strings[i]), Index);
Item := TMenuItem.Create(ListPopupMenu);
Item.Caption := ExtractFileName(Data.Items.Strings [i]);
Item.Tag := i;
Item.ImageIndex := i;
Item.OnClick := ActionMenu;
Add(Item);
end;
end;
end;
end else
begin
with ListPopupMenu.Items do
begin
while Count > 0 do Items[0].Free;
Add(NewItem('Нет программ', 0, False, False, nil, 0, 'MenuItem'))
end;
end;
end;
|