MMCC MASTHEAD
Mid-Michigan Computer Consultants - Bay City, Michigan
 


CONTENTS       (old style)
Mid-Michigan Computer Consultants
509 Center
Bay City, Michigan

Sales (989) 892-9242
Support (989) 686-8860

Plb-0268.cfm v1.0


plb-t010.cfm
 

ANSI Standard PL/B Language and Visual PL/B

Image List

NOTE TO OUR READERS
This web resource is written for our own use. But we feel strongly that the PL/B language should be shared with the software community. So feel free to use this at will! BUT PLEASE... if you find errors or omissions or have a better way to do something. TELL US! Dialog helps us all. Send e-mail to: support@mmcctech.com
An 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 List
PLBWIN 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).

STANDARD IMAGELIST BITMAPS PROVIDED BY PLBWIN


Custom Image List


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.
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.AddIcon  Giving MonkeyIndex    Using *Icon=Monkey.ICO
      My_ImageList.AddIcon  Giving Icon10131Index Using *Icon=10131
      My_ImageList.AddIcon  Giving Icon10132Index Using *Icon=10132
In 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.

Combining Default and Custom Image Lists


If you want both your own icons AND the ones that are provided by PLBWIN, you can do that with the following procedure.
  1. In the forms designer, use TOOLS/RESOURCES to add icons to the PLFORM's resources.
  2. At runtime, in your program:
    1. Do the FORMLOAD to have the resources available.
    2. Create your own image list object.
    3. Use the LoadStdToolBitMap method to load the standard icons into that list.
    4. 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.
Modifying the example above to combine lists you'd do this:
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=10132
Now 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 Benefit of Resources


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:


v1.10

Write to MMCC Technical Support at:               Send e-mail to MMCC.
MMCC - Technical Support
600 W. Midland
Bay City, MI 48708
(989) 686-8860
© 1997 - 2024 MMCC - All Rights Reserved