ImageList Widget and OCX Replacement¶
The ImageList is a control that enables you to store graphic images in an application. Other controls can then use the ImageList as a central repository for the images that they will use. Both bitmaps (.bmp files) and icons (.ico files) can be stored in the ImageList control. At runtime the ImageList is invisible, just like a Timer or a CommonDialog control, so you can place it anywhere on a form without interfering with the user interface.
In ABL, images can be loaded into a ImageList OCX control at design time or/and at runtime as well. In FWD this is possible only at runtime using ImageList widget API.
Important¶
At this moment ImageList conversion is fully implemented but at runtime, only add a new image to list is implemented.
IMAGELIST¶
To help applications using OCX components which are converted as 4GL extensions widgets that need Images from an ImageList control, we implemented an IMAGELIST widget as an extension to the 4GL language.
define variable hImageList as handle no-undo. define variable chImage as com-handle no-undo. define variable count as integer no-undo. define variable pcImageFile as character no-undo. def frame f with size-pixels 640 by 480 overlay view-as dialog-box title "ImageList widget". create imagelist hImageList assign frame = frame f:handle row = 3.62 column = 5 height = 1.2 width = 104 visible = false. assign count = hImageList:il-list-images:count(). pcImageFile = "~/img/save.ico":u. hImageList:il-list-images:add(count + 1, pcImageFile, chImage). hImageList:il-list-images:clear(). enable all with frame f. wait-for window-close of current-window.
The extension only exists in FWD, it doesn't work in OpenEdge. The API of the IMAGELIST widget is compliant with Microsoft ImageList OCX (VB 6.0 common control). This make the conversion process more straightforward.
Attributes¶
Attribute Name | OCX Name | Handle Type | Return Type | Read Only | Default | Description |
---|---|---|---|---|---|---|
IL-BACK-COLOR | BackColor | IMAGELIST | INTEGER | N | 0 | Returns/sets the background color used to display text and graphics in an object. |
IL-IMAGE-HEIGHT | ImageHeight | IMAGELIST | INTEGER | N | 0 | Returns/sets the height of a ListImage (IImage) object |
IL-IMAGE-WIDTH | ImageWidth | IMAGELIST | INTEGER | N | 0 | Returns/sets the width of a ListImage (IImage) object |
IL-LIST-IMAGES | ListImages | IMAGELIST | COM-HANDLE | Y | N/A | Returns a reference to a collection of ListImage object in an ImageList control (IImages). |
IL-MASK-COLOR | MaskColor | IMAGELIST | INTEGER | N | 0 | Returns/sets a value which determine the color to be transparent in ImageList graphical operation. |
IL-USE-MASK-COLOR | UseMaskColor | IMAGELIST | LOGICAL | N | FALSE | Returns/sets a value which determine the color to be transparent in ImageList graphical operation. |
Attribute Name | Handle Type | Return Type | Read Only | Default | Description |
---|---|---|---|---|---|
Count | LISTIMAGES | INTEGER | Y | 0 | Returns the number of objects in a collection. |
Get | LISTIMAGES | COM-HANDLE | Y | N/A | Returns a specific member of a Collection object (IImage) either by position or by key. |
Attribute Name | Handle Type | Return Type | Read Only | Default | Description |
---|---|---|---|---|---|
Index | LISTIMAGE | INTEGER | Y | 0 | Returns/sets the index of an object in a collection Read only at runtime. |
Key | LISTIMAGE | CHARACTER | N | ? | Returns/sets the unique string of an object in a collection. |
Picture | LISTIMAGE | USER-DEFINED | Y | N/A | Returns the image Picture. |
Tag | LISTIMAGE | ANY-TYPE | N | ? | Store any extra data needed for your program. |
Methods¶
Method Name | OCX Name | Handle Type | Return Type | Parameters | Description |
---|---|---|---|---|---|
IL-OVERLAY | Overlay | IMAGELIST | COM-HANDLE | Key1, Key2 | Create a composite third image out of two ListImage and returns a reference to the new object. |
Method Name | Handle Type | Return Type | Parameters | Description |
---|---|---|---|---|
Add | LISTIMAGES | COM-HANDLE | Index, Key, Picture | Adds a ListImage object to a ListImages and returns a reference to the created object (IImage). |
Clear | LISTIMAGES | NO-RETURN-VALUE | N/A | Remove all objects in a collection. |
Remove | LISTIMAGES | NO-RETURN-VALUE | Index or Key | Remove a specific member of a collection. |
Method Name | Handle Type | Return Type | Parameters | Description |
---|---|---|---|---|
Draw | LISTIMAGE | NO-RETURN-VALUE | hDC, x, y, Style | Draws the image to a given device context (DC) at a specified location using a specified style. imlNormal = 0 imlTransparent = 1 imlSelected = 2 imlFocus = 3 |
ExtractIcon | LISTIMAGE | NO-RETURN-VALUE | N/A | Create an icon from a ListImage object in an ImageList control. |
Events¶
In ABL, ImageList widget is visible only at design time when a property page allow developers to manage (add, remove, move) pictures in images container.
FWD does not support such capabilities.
At runtime ImageList widget is always hidden but allow to add and remove images via ImageList widget API. Because at runtime ImageList widget is always hidden, no events are fired or handled.
Conversion¶
FWD is capable to automatically convert the usages of Microsoft's Image List control from the Windows Common Controls library.
To enable the conversion create the file <procedurefile.p>.ext-hints with the following structure.
<extension> <ocx control-frame="ControlFrame" control-frame-handle="chControlFrame" com-handle="chControlFrame:ImageList" target-handle="hImageList" target-widget="imagelist" /> </extension>
The xml element ocx defines the CONTROL-FRAME hosting the progress bar control (control-frame), the com handle (control-frame-handle) of the control frame,
com handle property (com-handle) for referencing the progress bar in the control frame and the handle (target-handle) for the converted progress bar widget.
To give an example, the following code sample will convert with the xml configuration given above.
/* Definitions of handles for OCX Containers */ DEFINE VARIABLE ControlFrame AS WIDGET-HANDLE NO-UNDO. DEFINE VARIABLE chControlFrame AS COMPONENT-HANDLE NO-UNDO. /* ************************ Frame Definitions *********************** */ DEFINE FRAME fMain WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY SIDE-LABELS NO-UNDERLINE THREE-D AT COL 1 ROW 1 SIZE 80 BY 17 WIDGET-ID 100. /* ********************** Create OCX Containers ********************** */ CREATE CONTROL-FRAME ControlFrame ASSIGN FRAME = FRAME fMain:HANDLE ROW = 4.57 COLUMN = 20 HEIGHT = 4.76 WIDTH = 20 WIDGET-ID = 2 HIDDEN = yes SENSITIVE = yes. PROCEDURE control_load : /*------------------------------------------------------------------------------ Purpose: Load the OCXs Parameters: <none> Notes: Here we load, initialize and make visible the OCXs in the interface. ------------------------------------------------------------------------------*/ DEFINE VARIABLE UIB_S AS LOGICAL NO-UNDO. DEFINE VARIABLE OCXFile AS CHARACTER NO-UNDO. OCXFile = SEARCH( "imagelist.wrx":U ). IF OCXFile = ? THEN OCXFile = SEARCH(SUBSTRING(THIS-PROCEDURE:FILE-NAME, 1, R-INDEX(THIS-PROCEDURE:FILE-NAME, ".":U), "CHARACTER":U) + "wrx":U). IF OCXFile <> ? THEN DO: ASSIGN chControlFrame = ControlFrame:COM-HANDLE UIB_S = chControlFrame:LoadControls( OCXFile, "ImageList":U). RUN initialize-controls IN THIS-PROCEDURE NO-ERROR. END. ELSE MESSAGE "imagelist.wrx":U SKIP(1) "The binary control file could not be found. The controls cannot be loaded." VIEW-AS ALERT-BOX TITLE "Controls Not Loaded". END PROCEDURE. ...
Example¶
Below is a simple example on how IMAGELIST widget could be used in a real application:
define variable hImageList as handle no-undo. define variable chImage as com-handle no-undo. define variable count as integer no-undo. define variable pcImageFile as character no-undo. def frame f with size-pixels 640 by 480 overlay view-as dialog-box title "ImageList widget". create imagelist hImageList assign frame = frame f:handle row = 3.62 column = 5 height = 1.2 width = 104 visible = false. assign count = hImageList:il-list-images:count(). pcImageFile = "~/img/save.ico":u. hImageList:il-list-images:add(count + 1, pcImageFile, chImage). hImageList:il-list-images:clear(). enable all with frame f. wait-for window-close of current-window.
© 2019 Golden Code Development Corporation. ALL RIGHTS RESERVED.