Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Image lists

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Image lists
#9763
Posted by: Jeff Glatt 2007-01-11 15:53:51 Last edited by: Jeff Glatt 2007-06-16 18:58:19 (Total edited 4 times)
REXX GUI has a new GuiImageList function to make an image list (ie, a collection of bitmaps). These can be used for several things, but right now, they're mostly going to be used in TREE controls. There's a new example, treeimage.zip, on my examples site that contains an RPC project demonstrating this.

Speaking of which, RPC now supports putting bitmaps and icons inside an EXE you make. In order for this to work, each icon or bimap's name must start with a number, followed by an underscore. No two bitmaps can start with the same number. No two icons can start with the same number. (An icon and a bitmap can start with the same number).

For example, if you have two bitmaps used by a script, and you plan to make an EXE with those bitmaps stuffed into the EXE, then you should name them something like this:

1_MyBitmap.bmp
2_MyBitmap.bmp

And if you have one icon, you should name it something like this:

1_MyIcon.ico

I hate to resort to this whacky thing with prefacing names with a number, but unfortunately Microsoft's resource API is broken and doesn't support resource names like it is documented to do. Argh.

So, treeimage.zip contains a complete project with 2 bitmaps and 1 icon named accordingly. In treeimage.rex, you'll see how to create an imagelist with 2 bitmaps, and then give it to the tree control for display.

When defining the items in the tree, before any options such as "BOLD" or "HIDE", you'll put a | character, and then one or two numbers. The first number is the image number (where 1 is the first image) to display when the item is not selected. The second number, if supplied, is the image number to display when the item is selected. If not supplied, the selected image will be the same as the unselected image.

For example, here's a TREE item line where image 1 is displayed when the item is not selected, and image 2 is displayed when selected. The BOLD option is also specified.
mytreeitem.1 = "Parent label 1 | 1 2 | BOLD"
In order for a TREE to display images, when you add the control to your window, go into the TREE's Properties, and check the new box labeled "Images".

There are a number of preset images that are supplied by the operating system. Their names are:

LFARROWI
RGARROWI
DNARROWI
UPARROWI
COMBO
MNARROW
LFARROWD
RGARROWD
DNARROWD
UPARROWD
RESTORED
ZOOMD
REDUCED
RESTORE
ZOOM
REDUCE
LFARROW
RGARROW
DNARROW
UPARROW
CLOSE
BTNCORNERS
CHECKBOXES
CHECK
BTSIZE
SIZE

To use any of these, specify the 'STD' option when calling GuiImageList. Here I use two standard images in the imagelist:
var.0 = 2
var.1 = "DNARROW"
var.2 = "UPARROW"
guiimagelist('MyImages', 'STD', 'Var')
When you're done using an imagelist, it must be freed by calling GuiImageList, and specifying the "FREE" option.

A single imagelist can be used with numerous TREE controls.

Incidentally, you'll see that I create the imagelist, and send it to the TREE, within a handler called WM_INITDIALOG. This is a new handler for any window you create. It is called by GuiCreateWindow after the window and all its controls are created, but before the window is displayed. This eliminates the need to not show the window NORMAL, and waiting until after GuiCreateWindow returns to do any special initialization of the controls.

Run the treeimage.rex example to see a tree control with images in it. Then, load the treeimage project in RPC and create an EXE of it. Now you can delete treeimage.rex, the bitmaps, and icon. They'll all inside the exe now. When you run the EXE, you'll see it all.

NOTE: Any icon you add to an EXE, whose number is 1, is now used as the icon for your EXE, as well as the icon for your window title bar.
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Tue 2024-10-8  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0