Kbase P98439: ADM1: How to know the name of the smart Object that contains the focus at a given time
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/6/2004 |
|
Status: Unverified
GOAL:
How to know the name of the smart Object that contains the focus at a given time with ADM Smart Objects (ADM1 = smart object of Progress version 8)
FIX:
The following code relies on the ADM-OBJECT-HANDLE ADM1 smart object attribute, which happens to be the handle of the main frame of a smart object for a viewer and a browser. The following code tries to get the value of this attribute in all the running persistent procedures of the session (until it finds the good one if any), then compares this handle to the FRAME attribute of the FOCUS system handle.
To test it, on shall implement it in the CHOOSE trigger of a FLAT button (so it does not change the focus when choosing it) that is located in a test smart window.
DEFINE VARIABLE hproc AS HANDLE NO-UNDO.
DEFINE VARIABLE hFrame AS HANDLE NO-UNDO.
hproc = SESSION:FIRST-PROCEDURE.
DO WHILE hproc <> ?:
hFrame = ?.
RUN GET-ATTRIBUTE IN hproc ("ADM-OBJECT-HANDLE") NO-ERROR.
IF RETURN-VALUE <> ? AND RETURN-VALUE <> "" THEN
hFrame = WIDGET-HANDLE(RETURN-VALUE) NO-ERROR.
IF VALID-HANDLE(hFrame)
AND FOCUS:FRAME = hFrame THEN DO:
MESSAGE "The smart object that contains the widget that currently has the focus is:"
hProc:FILE-NAME
VIEW-AS ALERT-BOX INFO BUTTONS OK.
LEAVE.
END.
hProc = hProc:NEXT-SIBLING.
END.
IF hProc = ? THEN MESSAGE "The focus is not on a smart object!"
VIEW-AS ALERT-BOX INFO BUTTONS OK.