简体   繁体   English

C#/ WINAPI:SetWindowPos()

[英]C#/WINAPI: SetWindowPos()

I am using SetWindowPos() to try and send Windows to back/front of the z-order. 我正在使用SetWindowPos()尝试将Windows发送到Z顺序的后/前。 It seems to work for the most part however I am noticing for certain windows it just won't work although the function will return success. 它似乎在大多数情况下都有效,但是我注意到某些窗口虽然功能会返回成功,但它根本无法正常工作。

For example Window Task Manager seems to work perfectly fine but the other windows aren't responding properly to the function call. 例如,“窗口任务管理器”似乎工作正常,但是其他窗口对函数调用的响应不正确。

Any insights into what may be happening? 对可能发生的事情有任何见解吗? I know the information is sparse however I am not sure what to include. 我知道信息稀疏,但是我不确定要包括什么。

Pretty much seems to work using SetForegroundWindow . 使用SetForegroundWindow似乎可以正常工作。 From what I could discern it seems that using SetWindowPos and setting a window to HWND_TOP will make it top of the z-order following the foreground window. 据我HWND_TOP ,似乎使用SetWindowPos并将窗口设置为HWND_TOP会使它在前景窗口之后成为z顺序的顶部。 Meaning that once the foreground window is removed (minimized/closed) it will then be the next one at the TOP. 这意味着一旦前景窗口被删除(最小化/关闭),它将成为顶部的下一个窗口。

I too have hod problems with this across processes. 在整个过程中,我也对此有疑问。 This from the MS documentation: 这来自MS文档:

To use SetWindowPos to bring a window to the top, the process that owns the window must have SetForegroundWindow permission. 若要使用SetWindowPos将窗口置于顶部,拥有该窗口的进程必须具有SetForegroundWindow权限。

might be the cause? 可能是原因?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM