Release 10.1A: OpenEdge Development:
Progress 4GL Handbook

> ## Static object handles

> Static objects have handles just as dynamic objects do. As soon as a statically defined object is realized, it is given a handle just like a dynamic object. You can access this handle value using the `HANDLE` attribute of the static object. In this way, you can access an object’s attributes and methods using its handle just as you can for dynamic objects, as an alternative to using the object name. For example, the following code defines a handle variable and a static button. It then tries to display the button’s handle in the procedure’s default frame:

>     DEFINE VARIABLE hButton AS HANDLE      NO-UNDO.
>     DEFINE BUTTON bStaticButton LABEL "Static Button".
>     DISPLAY bStaticButton:HANDLE LABEL "Button handle:".
>     WAIT-FOR CLOSE OF THIS-PROCEDURE.

> However, this code doesn’t compile, as shown in Figure 18–2, because it tries to reference the button handle without the button being realized.

> Figure 18–2: Button handle error message

> The button itself hasn’t been realized in a frame and therefore has no handle. You can’t display its handle, or for that matter any of its other attributes, using the `widget`:`attribute` syntax because Progress has no way of identifying what the attributes of the object are until it can attach a handle to it. If you add the button itself to the `DISPLAY` statement, then you can reference its handle and other attributes:

>     DEFINE VARIABLE hButton AS HANDLE      NO-UNDO.
>     DEFINE BUTTON bStaticButton LABEL "Static Button".
>     DISPLAY bStaticButton bStaticButton:HANDLE LABEL "Button Handle:".
>     WAIT-FOR CLOSE OF THIS-PROCEDURE.

> Figure 18–3 shows the result.

> Figure 18–3: Static button example result

> Now that the static object has been realized, you can assign its handle to a variable and access its attributes through it. Here the code changes the button label and enables the button by setting its `SENSITIVE` attribute to `YES`:

>     DEFINE VARIABLE hButton AS HANDLE       NO-UNDO.
>     DEFINE BUTTON bStaticButton LABEL "Static Button".
>     DISPLAY bStaticButton bStaticButton:HANDLE LABEL "Button Handle:".
>     hButton = bStaticButton:HANDLE.
>     ASSIGN hButton:LABEL = "Enabled!"
>            hButton:SENSITIVE = YES.
>     WAIT-FOR CLOSE OF THIS-PROCEDURE.

> Figure 18–4 shows the result.

> Figure 18–4: Enabled button example result

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095