恢复窗口焦点返回到previous老板 [英] Restoring window focus back to previous owner

查看:165
本文介绍了恢复窗口焦点返回到previous老板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,坐落在系统托盘中,这双时点击打开一个窗口,比较规范的应用程序;但是,当您关闭该窗口,我想这是集中了窗口的的矿井建成还给焦点。

I've got an application that sits in the system tray, which when double clicked on opens a window, fairly standard; however, when you close the window I'd like the window that was focussed before mine was opened to be given back focus.

如果我弹出我的窗口由一个快捷键,我能够通过使用 GetForegroundWindow API调用我的窗口前恢复previous注重紧密表演,那么 SetForegroundWindow 方法后,我的窗口关闭(与第一次调用的值)来恢复焦点。当你通过系统托盘打开的窗口,然后这不起作用,因为用户已经基本上由系统托盘中的焦点。

If I pop my window up by a keyboard shortcut, I'm able to restore the previous focus on close by using the GetForegroundWindow API call before my window shows, then the SetForegroundWindow method after my window closes (with the value of the first call) to restore focus. This doesn't work when you open then window through the system tray, because the user has essentially made the system tray focus.

我用 GetForegroundWindow GetWindow 的组合尝试,而 GetTopMostWindow 来尝试导航Z顺序查找系统盘(去前提是系统托盘将跃升顶端之后的第二个窗口,因此在逻辑上的下一个下降将是原来前面)。我还没有成功,虽然,这些函数的结果是pretty的没用,因为他们似乎并没有给我任何的逻辑结构。

I've tried using a combination of GetForegroundWindow, GetWindow, and GetTopMostWindow to try to navigate the z-order to find the second window after the system tray (going on the assumption that the system tray will have jumped to the top, so logically the next one down would be the original front). I haven't had any success though, the results of those functions are pretty useless as they don't seem to give me any logical structure.

有没有人对我怎么能做到这一点任何想法?

Does anyone have any ideas on how I could achieve this?

我曾想过某种背景守望者,它只是坐在和监视器这是前窗和存储一个指向它,但是这将是片状的最好的。

I had thought about some kind of background watcher, which just sits and monitors which is the front window and stores a pointer to it, but that'll be flaky at best.

这是在Windows(我个人的x64 Server 2008上),并与.net 3.5。

This is on Windows (I'm personally on x64 Server 2008) and with .Net 3.5.

推荐答案

虽然这可能是一个很好的易用性功能,您可能知道,在Windows 7的托盘将拿到桌面上的(多)不那么突出的地方。

Although this might be a nice usability feature, you probably know that with Windows 7 the tray will get a (much) less prominent place on the desktop.

要真正做到这一点的唯一方法,就是监控Windows消息,并跟踪哪个窗口具有焦点之前,你的应用程序得到了焦点。除此之外AFAIK,有没有什么可以做。

The only way to actually do this, is to monitor for Windows messages and track which window had the focus before your application got focus. Besides that AFAIK, there's not much you can do.

这篇关于恢复窗口焦点返回到previous老板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆