Consultor Eletrônico



Kbase 21944: ADM2: Sample Procedure to Retrieve All the Widgets
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   04/04/2002
SUMMARY:

This Knowledge Base Solution applies to Progress Version 9.1x and higher. It provides a coding example which shows how to retrieve, at run time, all the widgets contained in a window.

SOLUTION:

To activate the trigger that initiates the widgets display, press F5 at run time.


/* program: widgettree.p Author: pmartine
Date: 04/04/02

Description: This procedure will trace in an ADM2 procedure all the
widgets of the procedure window.
To activate the trigger press F5 */

define variable myvar1
as CHAR VIEW-AS EDITOR INNER-LINES 2 INNER-CHARS 50 LABEL "Var1".
define variable myvar2 as CHAR VIEW-AS COMBO-BOX LABEL "Var2".
define variable myvar3 as DATE VIEW-AS RADIO-SET
RADIO-BUTTONS "Declaration of Independence", 07/04/1776,
"Lee Surrenders to Grant", 04/07/1865,
"Man Walks on Moon", 07/11/1969 LABEL "Var3".
define variable myvar4 as CHAR VIEW-AS FILL-IN LABEL "Var4".
define variable myvar5 as CHAR VIEW-AS SELECTION-LIST INNER-CHARS 20 INNER-LINES 5 LABEL "Var5".
DEFINE BUTTON bquit LABEL " &Quit " AUTO-ENDKEY.

define frame f1 myvar2 myvar3 WITH THREE-D SIDE-LABELS NO-BOX.
define frame f2 myvar4 myvar5 WITH THREE-D SIDE-LABELS NO-BOX.
DEFINE FRAME f3 myvar1 bquit WITH THREE-D SIDE-LABELS NO-BOX.

DEFINE VAR wWin AS WIDGET-HANDLE NO-UNDO.

CREATE WINDOW wWin ASSIGN
HIDDEN = YES
TITLE = "ADM2 Widget Tracer"
HEIGHT = 10
WIDTH = 80
MAX-HEIGHT = 35.81
MAX-WIDTH = 80.2
VIRTUAL-HEIGHT = 35.81
VIRTUAL-WIDTH = 80.2
RESIZE = YES
SCROLL-BARS = NO
STATUS-AREA = NO
BGCOLOR = ?
FGCOLOR = ?
THREE-D = yes
MESSAGE-AREA = no
SENSITIVE = yes.


VIEW FRAME f1 IN WINDOW wWin.
VIEW FRAME f2 IN WINDOW wWin.
VIEW FRAME f3 IN WINDOW wWin.
VIEW wWin.

ENABLE ALL WITH FRAME f3.
enable all with frame f2.
enable all with frame f1.

on "F5" anywhere run retrieve-widgets( active-window:handle ).

wait-for window-close of wwin.

procedure retrieve-widgets.
define input parameter wh-handle as handle no-undo.
DEF VAR whf AS HANDLE NO-UNDO.

if not valid-handle( wh-handle ) then return.
wh-handle = wh-handle:first-child /* First Frame */.

do while wh-handle <> ?:
if not valid-handle( wh-handle ) then return.

whf = if lookup("FRAME",LIST-QUERY-ATTRS(wh-handle)) = 0 THEN ?
ELSE wh-handle:FRAME.

if lookup("screen-value",LIST-QUERY-ATTRS(wh-handle)) > 0 then
message "TYPE:" wh-handle:type skip
"NAME:" wh-handle:name skip
"VALUE:" wh-handle:screen-value SKIP
if whf = ? THEN "" ELSE "FRAME: " + whf:NAME
view-as ALERT-BOX INFORMATION.
else
message "TYPE:" wh-handle:type skip
"NAME:" wh-handle:name skip
if whf = ? THEN "" ELSE "FRAME: " + whf:NAME
view-as ALERT-BOX INFORMATION.

if wh-handle:type = "FRAME" or wh-handle:type = "FIELD-GROUP" then
run retrieve-widgets( wh-handle:handle ).

wh-handle = wh-handle:next-sibling.
end. /* do while */

end procedure. /*retrieve-widgets*/