但不强制其位于顶部

但不强制其位于顶部

本文介绍了如何始终保持窗口可见,但不强制其位于顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建各种桌面小工具",我已禁用了手动最小化窗口,但是现在存在另一个问题:如果用户按下.

I'm creating a "desktop gadget" of sorts, I've disabled manual minimizing of the window, but now there is another problem: the system can still hide the window if the user presses +, for example.

以这种方式隐藏时,不会触发通常的最小化/调整大小/可见性事件.我想做几乎与 TopMost 类似的事情,但又不强制窗口顺序.

When hidden that way, no usual minimize/resize/visibility events are fired.I want to do something almost like TopMost, but without forcing the window order.

也许可以使用win32 API安装全局快捷方式事件,并将 TopMost 短暂地设置为true,但这听起来很骇人.

Maybe it's possible to install a global shortcut event using win32 API, and briefly set TopMost to true, but that sounds very hackish.

我找到了一个解决方案,但是它似乎在Windows 10上不起作用:可见的保持窗口考虑到它们的弃用,在Windows 10上将无法编写另一个实际选项,即编写实际的桌面小工具.

I found one solution, but it does not seem to work on Windows 10: Keeping window visible through "Show Desktop"/Win+D The other common option, which would be writing an actual desktop gadget, is not possible on Windows 10, given their deprecation.

是否还有其他方法可以使窗口始终可见(但不在屏幕顶部)?

Are there any other methods to keep a window visible (but not on top of the screen) at all moments?

推荐答案

此功能对我有用:

BOOL FixShowDesktop(HWND hWnd)
{
    HWND hWndTmp = FindWindowEx(NULL, NULL, L"Progman", NULL);
    if (hWndTmp)
    {
        hWndTmp = FindWindowEx(hWndTmp, NULL, L"SHELLDLL_DefView", NULL);
        if (hWndTmp)
        {
            SetWindowLongPtr(hWnd, -8, (LONG_PTR)hWndTmp);
            return TRUE;
        }
    }
    return FALSE;
}

请注意,此代码比>保持窗口可见通过显示桌面"/Win + D 进行操作,因为该窗口可能会被其他窗口(如其他任何窗口)所溢出.使用SetParent将窗口放置在所有其他窗口的下方.

Note, this code is a bit better then from Keeping window visible through "Show Desktop"/Win+D because the window can be overflowed by other windows (like any other window). Using SetParent places window under all other windows.

这篇关于如何始终保持窗口可见,但不强制其位于顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 02:27