2014-09-04 53 views
0

進行中11.3.2(Developer Studio 3.7 - Eclipse 3.8.2),根本不使用dot net:如何更改正在進行的活動應用程序?

如何將焦點切換到另一個窗口/應用程序/ w文件?

在windows 7/8中,關注窗口的順序與之前有所不同,並不總是顯示您希望覆蓋所有其他應用程序的窗口。

如果您打開3個窗口,並關閉第三個窗口,並且希望將焦點放在第二個已經最小化的窗口上,則第一個窗口會變爲焦點。

用WINDOW-STATE = WINDOW-NORMAL將它設置爲正常。但如何關注它呢?

回答

1

如果您運行的輔助窗口執着,你可以做這樣的事情:

在調用窗口:

/* In definitions */ 
DEFINE VARIABLE ghSecondWindow AS HANDLE  NO-UNDO. 

/* In a trigger */ 
RUN secondWindow.w PERSISTENT SET ghSecondWindow. 

/* Whenever you want to shift focus */ 
RUN setFocus IN ghSecondWindow. 

在 「SecondWindow」:

PROCEDURE setFocus: 
    /* Replace FILL-IN-1 with any widget that can gain focus */ 
    APPLY "ENTRY" TO FILL-IN-1 IN FRAME {&FRAME-NAME}. 
END PROCEDURE. 

然而,如果你不運行持久性窗口,您仍然可以通過步行窗口小部件樹,第一個當前窗口,然後第二個窗口(一旦您已經本地化它)來實現此目的。

快速和難看的代碼放在調用窗口,無論你想焦點轉移。這可能不適合您的需求,因此可能需要重寫。此外錯誤檢查是幾乎不在這裏,並與可能的永恆循環處理沒有錯誤檢查是不是真正的最佳實踐:

DEFINE VARIABLE hWin AS HANDLE  NO-UNDO. 
DEFINE VARIABLE hWidget AS HANDLE  NO-UNDO. 

/* Get the first child (widget) of the session */ 
ASSIGN 
    hWin = SESSION:FIRST-CHILD. 

/* Loop through all widgets in the session */ 
loop: 
DO WHILE VALID-HANDLE(hWin): 

    /* We've identified the correct Window! */ 
    IF hWin:TYPE = "WINDOW" AND hWin:TITLE = "Secondary Window" THEN DO: 

     /* ** Very Ugly** this could use better error checking etc! */ 
     /* Get the second field-group of the window */ 
     /* This will depend on your layout with different frames etc */ 
     /* What we really have is WINDOW:DEFAULT-FRAME:FIELD-GROUP:FIELD-GROUP */ 
     /* Field groups are really only present in the widget tree - they lack visual */ 
     /* representation */ 
     /* Read about field-groups in the online help! */ 
     ASSIGN 
      hWidget = hWin:FIRST-CHILD:FIRST-CHILD:FIRST-CHILD. 

     /* Loop through all widgets of the field-group */ 
     DO WHILE VALID-HANDLE(hWidget). 

      /* We've found the correct fill-in, give it focus */ 
      IF hWidget:TYPE = "FILL-IN" AND hWidget:LABEL = "Fill 1" THEN DO: 
       APPLY "ENTRY" TO hWidget. 
       LEAVE loop. 
      END. 

      /* Next window of the correct window */ 
      hWidget = hWidget:NEXT-SIBLING. 

     END. 
    END. 
    /* Next widget of the session */ 
    hWin = hWin:NEXT-SIBLING. 
END. 

你也可以做的「widget樹走」遞歸如果你喜歡它!

相關問題