Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System Image List

Status
Not open for further replies.

oldfoots

Technical User
Jul 29, 2003
5
US
How can I get an ICON for a specific Windows Program from the System Image List into an image on a form?
 
Seems there aren't ideas.

I don't know how to make exactly what u want, but it works fine.

Copy the screen (hitting the key) and the copy to an image editor, cut the image that u want and save it as an icon, bitmap o whatever u want.

--- LastCyborg ---
 
Thanks for the tip. If all else fails I will do that. However, I am trying to make a game menu program and I would like to automate the process. Currently on p18, cag3 gave a code snippet to question "get icon from api". I seem be be able to get the handle of the System Image List and the index of the ICON that I want from that list. What I am missing is how to get the ICON from the System Image List to an Image List on my form. From what I've been able to research, I should be able to do it using ImageList commands but nothing I've tried seems to work.
 
Finally figured it out. Code supplied below. Functions are in <shellapi.h>

Graphics::TIcon *myIcon = new Graphics::TIcon();
HIMAGELIST SystemImageListHandle;
HICON SytemImageListIconHandle;
SHFILEINFO FileInfo;

if (OpenDialog1->Execute())
{
// Get Large Icon System Image List Handle
SystemImageListHandle = (HIMAGELIST)SHGetFileInfo(
OpenDialog1->FileName.c_str(),
FILE_ATTRIBUTE_NORMAL,
&FileInfo,
sizeof(FileInfo),
SHGFI_SYSICONINDEX |SHGFI_LARGEICON);
// SHFILEINFO contains Handle of the Icon (hIcon) and the index of the
// Icon (iIcon) in the Large Icon System Image List. For Small Icon use
// SHGFI_SMALLICON in place of SHGFI_LARGEICON.

// Extract Icon from the Image List
SytemImageListIconHandle = ImageList_GetIcon(
SystemImageListHandle,
FileInfo.iIcon,
ILD_NORMAL);
// Set myIcon
myIcon->Handle = SytemImageListIconHandle;
// Display myIcon in Image1
Image1->Picture->Icon = myIcon;
}
else
{
ShowMessage(&quot;File Dialog would not open&quot;);
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top