Consultor Eletrônico



Kbase P11994: How to run a procedure located in SmartWindow from another S
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   21/08/2003
Status: Unverified

GOAL:

How to run a procedure located in SmartWindow from another SmartObject?

GOAL:

How to get the Handle of the Window a SmartPanel is placed on?

FACT(s) (Environment):

Progress 9.x

FIX:

The code below should be placed within the SmartObject, within a button or however you wish to call this.  Once executed it will get the current handle of the Procedure it is in, it will then check to see if this is a SmartWindow, if it is not, it will get the Previous Sibling and check if that is a SmartWindow.  This will be repeated until it reaches the SmartWindow all of these objects are placed on.  Once it has the handle, it can run the procedure located within the SmartWindow.



DEFINE VARIABLE cProc AS CHARACTER NO-UNDO.
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.

hProc = THIS-PROCEDURE:HANDLE.

DO WHILE VALID-HANDLE(hProc):
 cProc = DYNAMIC-FUNCTION('getObjectType':U IN hProc) NO-ERROR.
 IF cProc = "SmartWindow" THEN DO:
    RUN MyProc IN hProc. /*MyProc is the procedure name within the SmartWindow*/
    LEAVE.
 END. /*IF cProc = "SmartWindow*/
 hProc = hProc:PREV-SIBLING.
END. /* WHILE VALID-HANDLE(hProc) */