Consultor Eletrônico



Kbase P100965: How to determine which Frame is on top?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/02/2005
Status: Unverified

GOAL:

How to determine which Frame is the topmost?

GOAL:

How to know the top/bottom order of frames

GOAL:

How to determine which frame is on top or at the bottom?

FIX:

The following code has been tested successfully in 9.1E and 10.0B01. It relies on the fact that Progress internally maintains the list of widgets in a consistent way with their top/bottom position. This is a rather internal mechanism that could possibly change in the future so it is intentionally not described in the documentation. One is welcome to log a Enhancement Request to provide new 4GL methods on the official Enhancement Request System available on www.progress.com (in Support -> Resources)
/* Example to get the sorted list of frames of a window */
DEFINE VARIABLE ch AS CHARACTER NO-UNDO.
DEFINE VARIABLE cn AS CHARACTER NO-UNDO.

RUN framesFromTopToBottom (c-win:HANDLE, OUTPUT cn, OUTPUT ch).

MESSAGE cn VIEW-AS ALERT-BOX INFO BUTTONS OK.

/* Example to get the list of children frame of parent frames, run it is way */
RUN framesFromTopToBottom (FRAME fMain:HANDLE, OUTPUT cn, OUTPUT ch).

/* The procedure itself */
PROCEDURE framesFromTopToBottom :
DEFINE INPUT PARAMETER hParent AS HANDLE NO-UNDO.
DEFINE OUTPUT PARAMETER cOrderName AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER cOrderHandle AS CHARACTER NO-UNDO.
DEFINE VARIABLE lParentIsFrame AS LOGICAL NO-UNDO.
DEFINE VARIABLE hFrame AS HANDLE NO-UNDO.
IF NOT CAN-DO("WINDOW,FRAME", hParent:TYPE)
THEN RETURN ERROR "This procedure handles only the parent of type window or frame".
lParentIsFrame = hParent:TYPE = "FRAME".
/* for a frame, go from last child of first field-group*/
hFrame = IF lParentIsFrame THEN hParent:FIRST-CHILD:LAST-CHILD ELSE hParent:FIRST-CHILD.
DO WHILE hFrame <> ?:
/* ignore non frame widgets (can happen when parent is a frame) */
IF hFrame:TYPE = "FRAME" THEN ASSIGN
cOrderName = cOrderName + "," + hFrame:NAME
cOrderHandle = cOrderName + "," + STRING(hFrame).
hFrame = IF lParentIsFrame THEN hFrame:PREV-SIBLING ELSE hFrame:NEXT-SIBLING.
END.

ASSIGN
cOrderName = SUBSTR(cOrderName,2)
cOrderHandle = SUBSTR(cOrderHandle,2).
END PROCEDURE.