Как получить иконку 16x16 для типа файла?

Вопросы по программированию, не подходящие в другие разделы.

Модераторы: Naeel Maqsudov, C_O_D_E

Ответить
MOTOCoder
Сообщения: 542
Зарегистрирован: 14 янв 2008, 20:27
Откуда: Россия, Псков

30 май 2008, 01:10

Всем здравствуйте!
Возник один вопрос...
Нужно получить иконку, связанную с расширением для размещения в TListView.
Прога пишется на Delphi.
В общем, мне без проблем удалось получить иконку с помощью функции ExtractIcon.
Но проблема в том, что иконка получается большая, 32x32.При размещении в ListView с ViewStyle:=vsReport иконка скалится до 16x16, что очень сильно искажает её. В связи с этим, собственно, вопрос: как можно получить сразу иконку 16x16, зная имя файла с иконкой и её индекс?
Ни что так не ограничивает фантазию программиста, как компилятор...
BBB
Сообщения: 1272
Зарегистрирован: 27 дек 2005, 13:37

02 июн 2008, 13:19

ExtractIconEx ?

The ExtractIconEx function creates an array of handles to large or small icons extracted
from the specified executable file, dynamic-link library (DLL), or icon file.

Код: Выделить всё

UINT ExtractIconEx(
  LPCTSTR lpszFile,        // file name
  int nIconIndex,          // icon index
  HICON *phiconLarge,      // large icon array
  HICON *phiconSmall,      // small icon array
  UINT nIcons              // number of icons to extract
);
[b]Parameters[/b]
[i]lpszFile[/i]
[in] Pointer to a null-terminated string specifying the name of an executable file, DLL,
or icon file from which icons will be extracted. 
[i]nIconIndex [/i]
[in] Specifies the zero-based index of the first icon to extract. For example, if this value
is zero, the function extracts the first icon in the specified file. 
If this value is –1 and phIconLarge and phiconSmall are both NULL, the function returns the
total number of icons in the specified file. If the file is an executable file or DLL, the return
value is the number of RT_GROUP_ICON resources. If the file is an .ico file, the return
value is 1. 

Windows 95/98/Me, Windows NT 4.0 and later: If this value is a negative number and either
phIconLarge or phiconSmall is not NULL, the function begins by extracting the icon whose 
resource identifier is equal to the absolute value of nIconIndex. For example, use -3 to 
extract the icon whose resource identifier is 3. 

[i]phiconLarge[/i] 
[out] Pointer to an array of icon handles that receives handles to the large icons extracted 
from the file. If this parameter is NULL, no large icons are extracted from the file. 
[i]phiconSmall[/i] 
[out] Pointer to an array of icon handles that receives handles to the small icons extracted 
from the file. If this parameter is NULL, no small icons are extracted from the file. 
[i]nIcons[/i] 
[in] Specifies the number of icons to extract from the file. 
Сам не пробовал, но по описанию похоже на то, что нужно.
MOTOCoder
Сообщения: 542
Зарегистрирован: 14 янв 2008, 20:27
Откуда: Россия, Псков

02 июн 2008, 13:37

BBB, спасибо, то что надо.
Никак не приучусь пользоваться MSDN :)
Ни что так не ограничивает фантазию программиста, как компилятор...
GeorgeSoca
Сообщения: 0
Зарегистрирован: 12 окт 2015, 04:09
Откуда: Guam
Контактная информация:

14 окт 2015, 21:17

On our web, you can feel safe! Besides we use mirrored hard drives on all of our servers so we also take backup twice a day on separate servers. We use ISPmanager as the control panel. ISPmanager is a control panel that makes it easy to administer its Web site. With us you can place as many websites and domains you wish for a hosting account.
virtual hosting
Ответить