In Progress 11.3.2(Developer Studio 3.7 - Eclipse 3.8.2),根本不使用dot net:
如何将焦点切换到另一个窗口/应用程序/ w文件?
在Windows 7/8中,聚焦的窗口的顺序与以前略有不同,并不总是显示您想要拥有的所有其他应用程序的窗口。
如果您打开了3个窗口,并关闭了第3个窗口,并且想要关注最小化的第二个窗口,则第一个窗口会获得焦点。
使用WINDOW-STATE = WINDOW-NORMAL将其设置为正常。但是如何关注呢?
答案 0 :(得分: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.
In" 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.
您还可以执行"小部件树步行"如果您愿意,可以递归递送!