objects

lord_icon

Member
Greetings,
Using O E 10 on Windows;
How do I dynamicaly go through the objects in my container src - Window, so I can then query the type attribute?
Cheers.
Regards
 
The following little bit of code walks through the widget tree and shows messages of the type of each widget it encounters. The procedure runs itself recursively if the widget is a frame, so that it will find all the widgets in the main frame, even if you have a frame in a frame in a frame in a frame (don't know when Progress will get enough of these recursive calls due to stack problems etc, but I tried it with 3 nested frames and it went like a wounded bull at a gate).

To run simply run the internal procedure and pass it the handle of the main frame in your window so for instance:
RUN walkWidgets (INPUT FRAME DEFAULT-FRAME:HANDLE).

Code:
PROCEDURE walkWidgets:
  DEF INPUT PARAMETER ipHandle AS HANDLE NO-UNDO.      
  DEF VAR hHandle AS HANDLE NO-UNDO.

  IF NOT VALID-HANDLE(ipHandle)
  OR ipHandle:TYPE NE "FRAME":U 
  THEN RETURN.      

  hHandle = ipHandle:FIRST-CHILD.      

  DO WHILE VALID-HANDLE(hHandle):      
    MESSAGE hHandle:TYPE.      
    IF hHandle:TYPE EQ "FIELD-GROUP":U      
    THEN hHandle = hHandle:FIRST-CHILD.      
    ELSE DO:        
      IF hHandle:TYPE EQ "FRAME":U        
      THEN RUN walkWidgets (INPUT hHandle).        
      hHandle = hHandle:NEXT-SIBLING.      
    END. /* else do */   
  END. /* do while valid-handle */
END PROCEDURE.
 
Back
Top