Is there a way to travers all Windows in an Application?

Posted by goo on 30-Oct-2017 11:16

11.7

I would like to do something like this:

def var hObj as handle no-undo.

def var hChild as handle no-undo.

hObj = session:first-procedure.

do while valid-handle(hObj):

  hChild = hObj:first-child.

  do while valid-handle(hChild):

   /************** trying to find Windows **********/

    hChild = hChild:next-sibling.

  end. 

   hObj = hObj:next-sibling.

end.

Since I can't find any window, I am doing something wrong :-) I would like to i.e. Count all Windows or manipulate an attribute within the Window-handle.

Anyone done this?

//Geir Otto

Posted by Matt Gilarde on 30-Oct-2017 11:20

The chain of windows starts at SESSION:FIRST-CHILD. You can find all of the windows by traversing this chain.

All Replies

Posted by Matt Gilarde on 30-Oct-2017 11:20

The chain of windows starts at SESSION:FIRST-CHILD. You can find all of the windows by traversing this chain.

Posted by Kim Ward on 30-Oct-2017 11:22

Probably something like this (disclaimer: I've not tested this).

Perhaps you'll need to modify it to run recursively if you want to get every window. 

define variable hWindow as handle NO-UNDO.

assign hWindow = Session:handle:first-child.

do while hWindow <> ?:

    if lookup(hWindow:type, "WINDOW,DIALOG-BOX") <> 0 then 
    do:
        /* do whatever you need to do */
    end.
    

    assign hWindow = hWindow:next-sibling.

end.

Posted by goo on 30-Oct-2017 11:25

aaah, thanks :-)

This thread is closed