Accessibility
 
Home / Developer Center / Education & E-Learning Topic Center /

Developer Center Article

Icon or Spacer Icon or Spacer Icon or Spacer
Andrew Poulos
Andrew Poulos
www.apixel.com
 
Tips for manipulating images and text in Authorware 6.5


Authorware 6.5 includes new features and improvements to WinCtrls for controlling the placement and layout of graphics and text in your projects. To ensure consistent display results, it's important to follow best practices when including these elements.

In this article, I'll provide some equations and suggestions for helping you work with custom images, hexadecimal color calculations, and auto-scroll functionality.

 
How to make custom images appear in a ListBox  
First, export your images as bitmaps and crop them so that they are 16 x 16 pixels.
 
Next, you must set the Images property (after you set the Items property for the ListBox). Whenever the Items property is set, the Images property must be reset afterwards. The Images property is set as a return delimited list of bitmap file paths. If the bitmaps are in the same folder as your Authorware piece, then you may use relative paths. Otherwise, you must provide the full path to the images. (Generally, I prefer to use full paths.)
 
For example:
 

lst := wcDisplayControl(45, 59, 200, 100, "ListBox")
wcSetPropertyValue( lst, "Items", "foo\rbar\rfred" )

 

Now we'll define the list of images:

 

temp := FileLocation ^ "one.bmp\r"
temp := temp ^ FileLocation ^ "two.bmp\r"
temp := temp ^ FileLocation ^ "three.bmp"

 

Note that since the bitmaps are in the same folder as the Authorware piece, the image list could been have set as:

 

temp := "one.bmp\r"
temp := temp ^ "two.bmp\r"
temp := temp ^ "three.bmp"

 
Then we'll set the Images property:
 
wcSetPropertyValue( lst 2, "Images", temp )
 
Now that the Images property has been set, ImageIndex is used to associate each item with an image.
 
wcSetPropertyValue( lst , "ImageIndex", "0\r1\r2" )
 
How to calculate hexadecimal colors from an RGB triplet  
The new WinCtrls allow you to specify custom colors using hexadecimal values. Authorware is geared to RGB values. Many paint applications provide a way to display a color's value in many different formats but if you have an RGB triplet, you can calculate the hexadecimal value.
 
Given an RGB triplet (R, G, B), use this equation:
 
R/16 = x1 (a whole number) and y1 (a remainder)
G/16 = x2 (a whole number) and y2 (a remainder)
B/16 = x3 (a whole number) and y3 (a remainder)
 
This results in the hexadecimal value:
 
# x1 y1 x2 y2 x3 y3
 
Now—as this is a base 16 numbering system—any digit greater than 9 must use a letter. 10 is A, 11 is B, 12 is C, 13 is D, 14 is E, and 15 is F.
 
To see an example, first convert the RGB triplet (182, 0, 35) to a hexadecimal:
 
182/16 = 11 and 6
0/16 = 0 and 0
35/16 = 2 and 3
 
which returns the value:
 
#1160023
 
but the "digit" 11 must be base 16, so it becomes B. This changes the result to:
 
#B60023
 
To calculate an RGB triplet from a hexadecimal color, do the following:
 
Taking each pair of hexadecimal values individually, multiply the first digit by 16 and add the second digit.  
 
For example, convert the hexadecimal color value #B60023 to an RGB Triplet, using the following equation: 
 
The red value is B (that is 11) x 16 plus 6 which equals 176 + 6 which is 182.
The green value is 0 x 16 plus 0 which equals 0 + 0 which is 0.
The blue value is 2 x 16 plus 3 which equals 32 + 3 which is 35.
 
Creating an auto-scroll for the contents of a control 
WinCtrls does not provide a mechanism to auto-scroll but there is a workaround. The following is adapted from information that Chris Forecast posted to the Aware list server. It is presented here with a warning—that you are to use it at your own risk. These techniques use functions from WinAPI.U32.
 
ComboBox control  
Get the handle of your control using a function from WinCtrls.U32
 
ctrl_handle := wcGetPropertyValue(myCtrl, "Handle")
 
Put a Wait icon (set to zero seconds) between the code that displays the control and the following code to allow Authorware a chance to update the presentation window.
 
Next, set some user variables:
 
CB_FINDSTRINGEXACT := 344
CD_SHOWDROPDOWN := 335
CB_SETTOPINDEX := 348
 
You need to know the (zero-based) index of the item you want to show. For example:
 
index := 3
 
If you only know the text, then find the index using these functions from WinAPI.U32 and MemTools.U32:
 
buf := AllocMem(256) -- make it sufficiently large to hold your text
if buf<>0 then
   PokeString(buf, 0, "your text here")
   index := SendMessage(ctrl_handle, CB_FINDSTRINGEXACT, -1, buf)
   FreeMem(buf)
else
   index := -1
end if
 
Note: 'index' will equal -1 if this fails or if the search is unsuccessful.
 
To drop down the box use this syntax:
 
SendMessage(ctrl_handle, CB_SHOWDROPDOWN,1, 0)
 
and to put your selected item at the top:
 
SendMessage(ctrl_handle, CB_SETTOPINDEX, index, 0)
 
Memo control  
To automatically scroll a Memo control use this syntax:
 
EM_SCROLL := 181
SB_LINEUP := 0
SB_LINEDOWN := 1
SB_PAGEUP := 2
SB_PAGEDOWN := 3
SendMessage(ctrl_handle, EM_SCROLL, SB_LINEDOWN, 0)
 
Then adjust the 3rd argument, depending on which way you want to scroll.
 
That's it. Hopefully these suggestions will enhance the display of images and text in your projects. Maybe these recommendations have also given you some new ideas to try. Remember, if you have tips of your own that you'd like to share with the community, you can submit them into the Tips Library.
 

About the author
Andrew Poulos is senior programmer at Apixel Pty Ltd.  He’s the company’s designated Authorware expert and he’s been helping the Authorware community ever since he discovered that he could use his then fast 2400 baud modem and Lynx to access the Internet. Within the last year, he formed a partnership with Apurva Lawale of Singapore with the aim that, by working together, we can extend Authorware in imaginative ways.