MMCC's PL/B notes Notes home Intro History Article index v1.10 |
509 Center Bay City, Michigan Sales (989) 892-9242             Support (989) 686-8860 Image Lists
|
ImageListAn Image List is a collection of bitmat or icon images which can be applied to LISTVIEW, TOOLBAR, and TREEVIEW objects. For example, you attach an image list to a ToolBar and assign images to the buttons in that toolbar.Default Image ListPLBWIN provides a standard default image list that can be used if you don't want to build your own list. The last time we looked, that list contains 71 images (shown below).Custom Image List
STANDARD IMAGELIST BITMAPS PROVIDED BY PLBWIN
To build your own image list, first create the image list object then populate it with images and icons via the AddBmp and AddIcon methods. Images can be actual image files or they can be RESOURCES.Combining Default and Custom Image ListsMY_ImgList IMAGELIST MonkeyIndex FORM 3 //Index number of monkey in image list Icon10131Index FORM 3 //Index number of Icon 10131 in image list Icon10132Index FORM 3 //Index number of Icon 10132 in image list CREATE MY_ImageList,ImageSizeH=16,ImageSizeV=16 My_ImageList.AddIcon Giving MonkeyIndex Using *Icon=Monkey.ICO My_ImageList.AddIcon Giving Icon10131Index Using *Icon=10131 My_ImageList.AddIcon Giving Icon10132Index Using *Icon=10132In the above example, icons are added to the image list. You can't control the number of the element within the image list. Essentially they're added in the order that you do them. In the example abouve, Monkey is #1, Icon 10131 is #2, Icon 10132 is #3.If you want both your own icons AND the ones that are provided by PLBWIN, you can do that with the following procedure.The Benefit of ResourcesModifying the example above to combine lists you'd do this:
- In the forms designer, use TOOLS/RESOURCES to add icons to the PLFORM's resources.
- At runtime, in your program:
- Do the FORMLOAD to have the resources available.
- Create your own image list object.
- Use the LoadStdToolBitMap method to load the standard icons into that list.
- Use the AddIcon method to add your own icons to the list.
The standard list had 71 icons last time we looked. The icons you add will follow those and become 72, 73, etc.MY_ImgList IMAGELIST MonkeyIndex FORM 3 //Index number of monkey in image list Icon10131Index FORM 3 //Index number of Icon 10131 in image list Icon10132Index FORM 3 //Index number of Icon 10132 in image list CREATE MY_ImageList,ImageSizeH=16,ImageSizeV=16 My_ImageList.LoadStdToolBitMap //load stanard images to list My_ImageList.AddIcon Giving MonkeyIndex Using *Icon=Monkey.ICO My_ImageList.AddIcon Giving Icon10131Index Using *Icon=10131 My_ImageList.AddIcon Giving Icon10132Index Using *Icon=10132Now we find that Monkey is #72, Icon 10131 is #73, Icon 10132 is #74.
Note that it's important to use the Giving clause to recover the actual index number of your icons. If you just expect them to be 72, 73, and 74, then Sunbelt someday adds more icons to the default list, your program will break because your icons are farther down the list.The problem with adding icons one at a time is that those icon files must be available at runtime. If our case, we're distributing programs to users and don't really want to also be distributing a bunch of icons.
But there is a solution: The designer lets you add images and icons to a "resource" object that becomes part of the PLFORM. When you add icons to the image list by number, these come from your resources for the form! (See the discussion of this in article 620.)
Image numbers provided by PLBWIN
Note that numbers 1,2,3 were
created as RESOURCES in the Designer
Display created by UTIL-PLB\RESOURCE.PLS
See also:
- IMAGE LISTS.
- RESOURCES.
- ICONS where resources are used.
- BUTTONS where resources are used.
- Tool Bars where an image list is used.
- ICON/RESOURCE summary.
v1.10 |
Send e-mail to MMCC. |