2014-09-04 57 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树走”递归如果你喜欢它!

相关问题