Class TSystemImageList (unit SystemImageList)

Inherits from

TImageList

CE_Desc_Begin(TSystemImageList)} {TSystemImageList component which extends the TImageList component 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. It is derived from TImageList instead of TCustomImageList because \ components such TListView and TTreeView have properties of TImageList \ type. If it were derived from TCustomImageList, it would not be \ compatible with those properties. That would make it pretty useless; thanks \ Borland...err...Inprise.} {CE_Desc_End

Constructors


constructor Create(AOwner: TComponent);



Functions

function GetFileInformation(const APath: string; Attrs: TSystemFileAttributes; var Descr: string): integer;

CE_Desc_Begin(TSystemImageList.

function GetImageIndex(const APath: string; Attrs: TSystemFileAttributes): integer;

CE_Desc_Begin(TSystemImageList.

function GetVersion: TDFSVersion;


procedure Loaded;

I really couldn't give a flying doughnut about SetName, I just needed something I could override that would happen when the component was being created dynamically so I could create the handle.

procedure SetImageListHandle(Shared: boolean);

We don't want the system image list being streamed out to disk.

procedure SetName(const NewName: TComponentName);


procedure SetVersion(const Val: TDFSVersion);


procedure WriteState(Writer: TWriter);

EXTREMELY IMPORTANT!!!!

function GetHandle: HImageList;


function GetHeight: integer;


function GetShareImages: boolean;


function GetWidth: integer;


procedure SetImageSize(Val: TImageSize);

make a copy of it.

procedure SetShareImages(Val: boolean);


Properties

property Height : integer

CE_Desc_Begin(TSystemImageList.

property ImageSize : TImageSize

CE_Desc_Begin(TSystemImageList.

property ShareImages : boolean

CE_Desc_Begin(TSystemImageList.

property Version : TDFSVersion

CE_Desc_Begin(TSystemImageList.

property Width : integer

CE_Desc_Begin(TSystemImageList.

property Handle : HImageList

CE_Desc_Begin(TSystemImageList.

Events

Variables

FImageSize : TImageSize;



Constructors


constructor Create(AOwner: TComponent);


Functions


function GetFileInformation(const APath: string; Attrs: TSystemFileAttributes; var Descr: string): integer;

CE_Desc_Begin(TSystemImageList.GetFileInformation)} {The <%BOLD%>GetFileInformation<%BOLD0%> method is identical to the \ <%BOLD%><%LINK GetImageIndex%><%BOLD0%> method with the exception that it also \ retrieves the system description text for the file type. This text is what \ you see in the <%BOLD%>Type<%BOLD0%> column of Explorer. Simply pass a string variable in the <%BOLD%>Descr<%BOLD0%> parameter and it \ will be assigned the system description text. All other aspects of this method are identical to <%BOLD%>GetImageIndex<%BOLD0%>. <%SEEALSO GetImageIndex%> {CE_Desc_End

Only need Attrs if APath doesn't exist, otherwise just pass []


function GetImageIndex(const APath: string; Attrs: TSystemFileAttributes): integer;

CE_Desc_Begin(TSystemImageList.GetImageIndex)} {The <%BOLD%>GetImageIndex<%BOLD0%> method is used to retrive the index into \ the image list of given filename or directory. The return value is the image \ index. You must specify the full pathname if you want the system to determine the \ attributes of the file. In this case, you can simply pass an empty set ( [] ) \ to the <%BOLD%>Attrs<%BOLD0%> parameter. If you do not specify the full pathname, or the file simply does not exist, \ you must specify the attributes to be used in determining the image index. The <%BOLD%>Attrs<%BOLD0%> parameter is a set of zero or more of the following \ values: <%TABLE%><%BOLD%>sfaReadOnly<%BOLD0%> The file or directory is read-only. \ Applications can read the file but cannot write to it or delete it. In the \ case of a directory, applications cannot delete it. <%BOLD%>sfaHidden<%BOLD0%> The file or directory is hidden. It is not \ included in an ordinary directory listing. <%BOLD%>sfaSystem<%BOLD0%> The file or directory is part of, or is used \ exclusively by, the operating system. <%BOLD%>sfaDirectory<%BOLD0%> The "file or directory" is a directory. <%BOLD%>sfaArchive<%BOLD0%> The file or directory is an archive file or \ directory. Applications use this flag to mark files for backup or removal. <%BOLD%>sfaNormal<%BOLD0%> The file or directory has no other attributes set. \ This attribute is valid only if used alone. <%BOLD%>sfaTemporary<%BOLD0%> The file is being used for temporary storage. \ File systems attempt to keep all of the data in memory for quicker access \ rather than flushing the data back to mass storage. A temporary file should be \ deleted by the application as soon as it is no longer needed. <%BOLD%>sfaCompressed<%BOLD0%> The file or directory is compressed. For a \ file, this means that all of the data in the file is compressed. For a \ directory, this means that compression is the default for newly created files \ and subdirectories. <%BOLD%>sfaOffline<%BOLD0%> The data of the file is not immediately available. \ Indicates that the file data has been physically moved to offline storage. <%ENDTABLE%> <%SEEALSO GetFileInformation%> <%EXAMPLE%> <%TEXT%> This example retrieves the image index for a file or directory that does \ exist. For example, if you were populating a listview with the files in a \ directory on the user's system, this would be appropriate. <%CODE%> function AddListItem(const ARealFilename: string); var Item: TListItem; s: string; begin SomeListView.Items.BeginUpdate; try Item := SomeListView.Items.Add; // ARealFilename must have full path information Item.Caption := ExtractFileName(ARealFileName); // The filename is real, so let the system figure out the attributes. Item.ImageIndex := SomeSystemImageList.GetImageIndex(ARealFilename, []); finally SomeListView.Items.EndUpdate; end; end; <%TEXT%> This example retrieves the image index for a file type based on it's \ extension. This is appropriate for if you had a listview that was to be filled \ with filenames that did not exist; a zip file viewer or the files on an FTP \ server, for example. <%CODE%> function AddListItem(const AFakeFilename: string, IsADirectory: boolean); var Item: TListItem; s: string; Attrs: TSystemFileAttributes; begin SomeListView.Items.BeginUpdate; try Item := SomeListView.Items.Add; // AFakeFilename does not exist, we must supply the attributes. if IsADirectory then Attrs := [sfaDirectory] // tell it we want the folder image index. else Attrs := [sfaNormal]; // figure it out based on file extension. Item.ImageIndex := SomeSystemImageList.GetImageIndex(AFakeFilename, Attrs); finally SomeListView.Items.EndUpdate; end; end; {CE_Desc_End

Only need Attrs if APath doesn't exist, otherwise just pass []


function GetVersion: TDFSVersion;


procedure Loaded;

I really couldn't give a flying doughnut about SetName, I just needed something I could override that would happen when the component was being created dynamically so I could create the handle. In a windowed component, I could override CreateWnd which would make sense, but this little freak doesn't make it's CreateHandle virtual. Matter of fact, it makes damn little of itself virtual, making my life a lot harder than it should be. Can you tell I'm really ticked off at the moment? If it isn't loading, create the handle. If it is, wait until all properties have been loaded before doing it so we don't have to recreate it every time one changes.


procedure SetImageListHandle(Shared: boolean);

We don't want the system image list being streamed out to disk. It is like a couple of meg in size.


procedure SetName(const NewName: TComponentName);


procedure SetVersion(const Val: TDFSVersion);


procedure WriteState(Writer: TWriter);

EXTREMELY IMPORTANT!!!!


function GetHandle: HImageList;


function GetHeight: integer;


function GetShareImages: boolean;


function GetWidth: integer;


procedure SetImageSize(Val: TImageSize);

make a copy of it. This can be quite slow.


procedure SetShareImages(Val: boolean);


Properties


property Height : integer

CE_Desc_Begin(TSystemImageList.Height)} {The <%BOLD%>Height<%BOLD0%> property is used to report the height of the \ images contained in the list. You can not directly change this value since \ it is dictated by the system. To change the size of images in the list, use \ the <%BOLD%><%LINK ImageSize%><%BOLD0%> property. <%SEEALSO Width, ImageSize%> {CE_Desc_End


property ImageSize : TImageSize

CE_Desc_Begin(TSystemImageList.ImageSize)} {<%BOLD%>ImageSize<%BOLD0%> indicates what size image is to be provided by the \ component. Possible values are: <%TABLE%><%BOLD%>isLarge<%BOLD0%> The large image list is most commonly used \ for list view controls with ViewStyle set to vsIcon. <%BOLD%>isSmall<%BOLD0%> The small image list is most commonly used for list \ view controls with ViewStyle set to a value other than vsIcon, and also tree \ view controls. <%ENDTABLE%> If you need to determine the exact size of either large or small images in the \ list, use the <%BOLD%><%LINK Height%><%BOLD0%> and <%BOLD%><%LINK Width%> \ <%BOLD0%> properties. <%SEEALSO Height, Width%> {CE_Desc_End


property ShareImages : boolean

CE_Desc_Begin(TSystemImageList.ShareImages)} {The <%BOLD%>ShareImages<%BOLD0%> property is used to indicate whether the \ component should use the <%BOLD%>real<%BOLD0%> system image list or make a \ copy of it for the components used. Using the real system image list means any changes made to it will affect the \ <%ITALIC%><%BOLD%>entire system<%BOLD0%><%ITALIC0%> until it is restarted. <%NOTE%>For safety reasons, you should always set <%BOLD%>ShareImages<%BOLD0%> \ to TRUE when it is possible. The drawback to doing this is that it can be \ quite time consuming to make the initial copy of the system's image list (it \ can be very large, upwards of several megabytes). <%SEEALSO Handle%> {CE_Desc_End


property Version : TDFSVersion

CE_Desc_Begin(TSystemImageList.Version)} {Displays the version number of the component. This allows you to easily \ compare the version installed with the version you *think* you are using. The property editor for this property also displays the address to my web site \ where you can find the most current version of this component, along with many \ other freeware components written by myself and others.} {CE_Desc_End


property Width : integer

CE_Desc_Begin(TSystemImageList.Width)} {The <%BOLD%>Width<%BOLD0%> property is used to report the width of the \ images contained in the list. You can not directly change this value since \ it is dictated by the system. To change the size of images in the list, use \ the <%BOLD%><%LINK ImageSize%><%BOLD0%> property. <%SEEALSO Height, ImageSize%> {CE_Desc_End


property Handle : HImageList

CE_Desc_Begin(TSystemImageList.Handle)} {The <%BOLD%>Handle<%BOLD0%> property is the Win32 handle of the image list in \ use. If the <%BOLD%><%LINK ShareImages%><%BOLD0%> property is TRUE, the \ handle is the <%BOLD%>REAL<%BOLD0%> system image list. That means any changes \ to it will affect the <%ITALIC%><%BOLD%>entire system<%BOLD0%><%ITALIC0%>. If \ <%BOLD%>ShareImages<%BOLD0%> is FALSE, the component has made a copy of the \ system image list and changes will affect only the component. <%SEEALSO ShareImages%> {CE_Desc_End


Events


Variables


FImageSize : TImageSize;