Question How to move a window to the top

Hi guys,

I'm working on a multi-window application.

This is my scenario:

From my main window (we will call it "parent", I run another one (we will call it the "child") with the persistent option. The user can hide the child behind the parent and forget he already launched the child.

Code:
DO:
    /* Handle */
    DEFINE VARIABLE hWctrw AS HANDLE      NO-UNDO.
    /* Logical */
    DEFINE VARIABLE lFound AS LOGICAL INIT FALSE  NO-UNDO.
    
    hWctrw = SESSION:FIRST-PROCEDURE.
    DO WHILE VALID-HANDLE(hWctrw) :
        IF hWctrw:NAME MATCHES "*myChildWindow*" THEN DO:
            lFound = TRUE.
            LEAVE.
        END.   
        hWctrw = hWctrw:NEXT-SIBLING.
    END.

    IF lFound = TRUE THEN DO:
        hWctrw:MOVE-TO-TOP().

    END.
        
    ELSE
        RUN myChildWindow.w PERSISTENT (some value).

    

END.
 

Osborne

Active Member
Does using CURRENT-WINDOW solve the problem?:
Code:
    DO WHILE VALID-HANDLE(hWctrw) :
        IF hWctrw:NAME MATCHES "*myChildWindow*" THEN DO:
            lFound = TRUE.
            CURRENT-WINDOW = hWctrw:CURRENT-WINDOW.
            LEAVE.
        END.  
        hWctrw = hWctrw:NEXT-SIBLING.
    END.

    IF lFound = TRUE THEN DO:
        /* hWctrw */ CURRENT-WINDOW:MOVE-TO-TOP().
        /* or APPLY "ENTRY" TO CURRENT-WINDOW. */

    END.
 
Top