Mega Code Archive

 
Categories / Delphi / Examples
 

Lost ToolBar buttons glyphs

Title: Lost ToolBar buttons' glyphs Question: I built my programm with Toolbar and ImageList with images for Toolbar buttons but when I run my application on different PC all images are disappeared. Why? Answer: When you're using ImageList component you should take care that it won't work correct under different versions of Windows, since it is quite dependent from version of Microsoft's COMCTL32.DLL library. For preventing different behaviour of your Imagelist there are two ways: 1. To install last update of COMCTL32.DLL from Microsoft site: http://www.microsoft.com/msdownload/ieplatform/ie/comctrl.asp on every PC where your application will execute. 2. To use bitmaps stored in your application's resources. Following this way you don't need to care about COMCTL32.DLL version. For using bitmpas from resource you should follow next steps: 1. Export all bitmaps stored in your ImageList into one bitmap file (use "Export" button in ImageList editor) for example "toolbar.bmp". 2. Create RC script manually or using some editors (for example Resource Builder from http://www.sicomponents.com/rbldr.html). 2.1. For manually creating just create a file for ex. bitmaps.rc with content: TOOLBARBMPS BITMAP "toolbar.bmp". 3. Compile this file using BRCC32.EXE (placed in Delphi's BIN directory) or some other compiler. For using BRCC32.EXE just type in command line: BRCC32.EXE bitmaps.rc press ENTER and you'll get bitmaps.res file. 4. Add to your program code following directive: {$R "bitmaps.res"} 5. In FormCreate event use ResourceLoad(ImgList.rtBitmap, 'TOOLBARBMPS', clSOME_COLOR_FOR_TRANCPARENT); method of image list for loading images into imagelist. 6. Rebuild your application. And you will always have bitmaps independent from version of COMCTL32.DLL. P.S. Don't forget to clear imagelist after exporting images for reducing size of your application executable file.