Unit SystemImageList

Standard defines for all Delphi Free Stuff components } {-----------------------------------------------------------------------------} { TSystemImageList v1.00 Beta 2 } {-----------------------------------------------------------------------------} { A component to extend the TImageList so that it gives access to the system } { image list. } { Copyright 1998, Brad Stowers. All Rights Reserved. } { This component can be freely used and distributed in commercial and private } { environments, provied this notice is not modified in any way and there is } { no charge for it other than nomial handling fees. Contact me directly for } { modifications to this agreement. } {-----------------------------------------------------------------------------} { Feel free to contact me if you have any questions, comments or suggestions } { at bstowers@pobox.com. } { The lateset version will always be available on the web at: } { http://www.pobox.com/~bstowers/delphi/ } { See SystemImageList.txt for notes, known issues, and revision history. } {-----------------------------------------------------------------------------} { Date last modified: June 2, 1998 } {-----------------------------------------------------------------------------} {CE_Desc_Begin(SystemImageList.pas)} {This unit provides the <%LINK TSystemImageList%> component which extends \ the TImageList so that it gives access to the Win32 system image list. The \ system image list is a list of images owned by the Win32 operating system \ that is made up of all the images the OS uses in things like Explorer.} {CE_Desc_End

Classes

TSystemImageList - CE_Desc_Begin(TSystemImageList)} {TSystemImageList component which extends the TImageList component so that \ it gives access to the Win32 system image list.

Functions

GetFileInfo - CE_Desc_Begin(GetFileInfo)} {This function is exactly the same as <%BOLD%><%LINK GetIconIndex%><%BOLD0%> \ except that it takes an extra variable parameter that is assigned the system \ description for the file.
GetIconIndex - CE_Desc_Begin(GetIconIndex)} {Retrieves the index into the system image list of a file or directory item.
GetSystemImageList - CE_Desc_Begin(GetSystemImageList)} {<%BOLD%>GetSystemImageList<%BOLD0%> is a function that is can be used to get \ the handle of the system's large and small image list.
Register -

Types

TImageSize
TSystemFileAttribute
TSystemFileAttributes

Constants

DFS_COMPONENT_VERSION

Variables


Functions


function GetFileInfo(const APath: string; Attrs: DWORD; var Descr: string): integer;

CE_Desc_Begin(GetFileInfo)} {This function is exactly the same as <%BOLD%><%LINK GetIconIndex%><%BOLD0%> \ except that it takes an extra variable parameter that is assigned the system \ description for the file. The contents of this string parameter does not \ matter when the function is called, it is used strictly for output. <%SEEALSO GetIconIndex%> {CE_Desc_End

File doesn't exist, so Windows doesn't know what to do with it. We have to tell it by passing the attributes we want, and specifying the SHGFI_USEFILEATTRIBUTES flag so that the function knows to use them.


function GetIconIndex(const APath: string; Attrs: DWORD): integer;

CE_Desc_Begin(GetIconIndex)} {Retrieves the index into the system image list of a file or directory item. \ If the item does not exist, the <%BOLD%>Attrs<%BOLD0%> parameter is used to \ describe its attributes. If the file does exist, <%BOLD%>Attrs<%BOLD0%> is \ ignored. The <%BOLD%>Attrs<%BOLD0%> parameter accepts any of the \ <%BOLD%>FILE_ATTRIBUTE_xxx<%BOLD0%> constants ORed together bitwise, or 0 if \ the system should determine the attributes itself. You can find a list of \ these constants in the Win32.hlp file under the \ <%BOLD%>GetFileAttributes<%BOLD0%> topic. <%SEEALSO GetFileInfo%> <%EXAMPLE%> <%TEXT%> If you wanted to get the index of a file, say c:\windows\notepad.exe, that did \ exist, you would call it like this: <%CODE%> Index := GetIconIndex('c:\windows\notepad.exe', 0); <%TEXT%> If you wanted to get the index for a file that did not exist, you would need \ to specify what file attributes should be used in determining the image index. <%CODE%> Index := GetIconIndex('c:\bogus\dir\badfile.html', FILE_ATTRIBUTE_NORMAL); {CE_Desc_End

SHGetFileInfo puts the requested information in the SFI variable, but it also can return the handle of the system image list. We just pass an empty file because we aren't interested in it, only the returned handle.


function GetSystemImageList(Large: boolean): HImageList;

CE_Desc_Begin(GetSystemImageList)} {<%BOLD%>GetSystemImageList<%BOLD0%> is a function that is can be used to get \ the handle of the system's large and small image list. This list is \ <%BOLD%>owned by the system<%BOLD0%>. It is <%BOLD%>NOT<%BOLD0%> a copy. The <%BOLD%>Large<%BOLD0%> parameter indicates whether to return the image \ list handle that contains large or small icons. You should <%ITALIC%><%BOLD%>never<%BOLD0%><%ITALIC0%> free this handle when \ you are done with it. Doing so will leave the entire OS without an image \ list. Explorer looks damn funny that way.} {CE_Desc_End

procedure Register;


Types


TImageSize = (isLarge, isSmall);

TSystemFileAttribute = (sfaReadOnly, sfaHidden, sfaSystem, sfaDirectory,
     sfaArchive, sfaNormal, sfaTemporary ,sfaCompressed, sfaOffline);
TSystemFileAttribute is used to provide a Delphi-ish interface for the various Win32 file attributes.
TSystemFileAttributes = set of TSystemFileAttribute
TSystemFileAttributes is a set of TSystemFileAttribute. This allows you to provide more than a single attribute at one time.

Constants

DFS_COMPONENT_VERSION = 'TSystemImageList v1.00 Beta 2'

ERROR! Only available for Win32! } {$ENDIF} {CE_Desc_Begin(@LIST_OVERVIEW)} {<%LINK TSystemImageList%> is the only class provided with this component. There are several unit level functions that are used by the component that \ I have provided in case you want do things at a lower level than using the \ component.} {CE_Desc_End} {CE_Desc_Begin(@HIERARCHY_OVERVIEW)} {Their is only the <%LINK TSystemImageList%> component in this package, and it \ descends from TImageList.} {CE_Desc_End} {CE_Desc_Begin(@UNIT_OVERVIEW)} {The <%LINK TSystemImageList%> component is wholly contained in the \ SystemImageList.pas unit.} {CE_Desc_End

Variables