The screen shot above shows the debugging interface for code that creates a custom Icon Cache file for an application. After spending weeks grappling with palettes (not a trivial matter), and Icons being returned with indeterminate bit counts by API functions, and complications surrounding different screen resolutions, and the sometimes strange behavior of the save and load functions associated with ImageLists and bitmaps, I finally hit upon a plan to create a custom Icon file that avoids all these problems and meets my objectives. Having a cache of icons required by a certain program is much faster than going through the Windows registry and then hopping all over a hard drive looking for icons.
This demo illustrates one way to create an icon cache for a program. The icon cache file it creates has the following format:
4 bytes - number icons cached in the file
4 bytes - width of icons
4 bytes - height of icons
followed by the raw pixel data for the XOR color bitmap in pf24bit format
followed by the raw pixel data for the And mask in pf1bit format
followed immediately by another XOR map, another AND map etc
By saving the pixel data for the color XOR bitmap in 24 bit format the code avoids the problems of different screen display settings and problems with API routines returning bitmaps from icons of indeterminate color depth and also avoids problems of icon palettes (returned as zero) and strange colored icons that can result. The API icon routines will accept a 24 bit (XOR) bitmap for the icon creation routine, and by using 24 bits the need for palette data is eliminated, and by fixing the pixel data size at 24 bits the need to be concerned about different screen resolutions, default values and other complications is eliminated (at the price of a couple of bytes per pixel to store the Icon data). When the cache is created with a smaller bit count I encountered problems with uncolored icons, greyed icons, palette complications, icons covered with colored films at 16 bit resolution, changing bit counts that take place when 16 bit bitmaps are loaded and saved, and so finally I opted for a true color bitmap for the raw bitmap pixel data for the icon cache and after struggling with issues for a couple of weeks the code just wrote itself in an hour or two.
The open file button is set to open a dialogue pointing to an intial directory of 'c:\windows\system' and the file filter is set to Shell32.dll for convenience. Hit the Get Icon button a number of times to load some icons from the shell into the image list, then hit the save button to save the icons as a cache file and then reload the cache file and recreate the icons by hitting the load button. You can then surf through the icons recreated from the cache stored on the image list by hitting the view button to cycle through icons on the list.
The code for the project can be downloaded as a Delphi 3 / Delphi 5 project in a zip file ... icon_cache.zip 17 KB or you can view the text file here ... icon_cache.txt
A Unified Field Theory
![]()
The Unified Field Theory
is also available as a zip file -> unified.zip
Introduction :The Pioneer Effect and the New Physics. A brief description of the new physics required to explain the 'Pioneer Effect', which is the constant deceleration of space craft as they fly through space.

