在 windows7 上将窗口设置为始终保留在桌面上

发布于 2024-09-01 21:43:53 字数 773 浏览 5 评论 0原文

我正在尝试将我的窗口设置为桌面的子窗口,我这样做是这样的:

HWND ProgmanHwnd = 
                ::FindWindowEx(
                    ::FindWindowEx(
                        ::FindWindow(L"Progman", L"Program Manager"), 
                        NULL, 
                        L"SHELLDLL_DefView", 
                        L""), 
                    NULL, 
                    L"SysListView32", 
                    L"FolderView");
SetParent(m_hWnd, ProgmanHwnd);

这在 windowsXP 中工作正常,我的窗口位于所有窗口下方,当我按“显示桌面”选项时,窗口将显示所有内容其他“正常”窗口被隐藏。

但是在Win7中,当我执行上述代码时,不会显示相同的窗口,在spy++中,我可以看到我的窗口是SysListView32的子窗口,但它不显示(并且它具有WM_VISIBLE样式)?

我缺少什么?或者从winXP到win7发生了什么变化?我怎样才能做到这一点才能在win7上工作?

更新: 这与航空主题有关,因为如果我将桌面主题更改为基本主题,则会显示窗口,但如果我切换回航空主题之一,则会再次隐藏。

谢谢

I'm trying to set my window a child of the desktop, and i'm doing this like this:

HWND ProgmanHwnd = 
                ::FindWindowEx(
                    ::FindWindowEx(
                        ::FindWindow(L"Progman", L"Program Manager"), 
                        NULL, 
                        L"SHELLDLL_DefView", 
                        L""), 
                    NULL, 
                    L"SysListView32", 
                    L"FolderView");
SetParent(m_hWnd, ProgmanHwnd);

This works fine in windowsXP, my window is underneath all windows and when i press the "show desktop" option the window shows and all other "normal" windows are hide.

But in Win7 when i do the above code the same window is not displayed, in spy++ i can see that my window is a child window of the SysListView32 but it not display (and it has the WM_VISIBLE style)?

What i'm missing? or what changed from winXP to win7? how can i do this to work on win7?

Update:
It's got something to do with aero theme, because if i change the desktop theme to the basic then the window is displayed, but if i switch back to one of the aero theme then is hided again.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

命硬 2024-09-08 21:43:53

我尝试了你的代码,它与我的测试 MFC 应用程序配合得很好。除非您在 SetParent 之前需要双冒号。你引用的代码放在哪里了?我已将其放入 OnCreate 函数中。工作没有问题。

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    // create a view to occupy the client area of the frame
    if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
        CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
    {
        TRACE0("Failed to create view window\n");
        return -1;
    }

    HWND ProgmanHwnd = 
        ::FindWindowEx(
            ::FindWindowEx(
                ::FindWindow(L"Progman", L"Program Manager"), 
                NULL, 
                L"SHELLDLL_DefView", 
                L""), 
            NULL, 
            L"SysListView32", 
            L"FolderView");
    ::SetParent(m_hWnd, ProgmanHwnd);

    return 0;
}

I tried your code and it works fine with my test MFC app. Except you need double colon before SetParent. Where did you put the code that you quote? I've put mine in OnCreate function. Works without problems.

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    // create a view to occupy the client area of the frame
    if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
        CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL))
    {
        TRACE0("Failed to create view window\n");
        return -1;
    }

    HWND ProgmanHwnd = 
        ::FindWindowEx(
            ::FindWindowEx(
                ::FindWindow(L"Progman", L"Program Manager"), 
                NULL, 
                L"SHELLDLL_DefView", 
                L""), 
            NULL, 
            L"SysListView32", 
            L"FolderView");
    ::SetParent(m_hWnd, ProgmanHwnd);

    return 0;
}
把回忆走一遍 2024-09-08 21:43:53

桌面窗口是 ProgMan->SHELLDLL_DefView->SysListView32 的一部分
而不是winxp中直接在程序下。

让下面用java编写的代码片段

尝试{
NativeCall.init();
IntCall ic = new IntCall("user32.dll", "FindWindowA");
父= ic.executeCall(新对象[] {
“ProgMan”、“程序经理”});
ic.destroy();

    } catch (Exception e) {
        e.printStackTrace();
    }
    System.out.println(" parent :"+parent);




    try {
        NativeCall.init();
        IntCall ic = new IntCall("user32.dll", "FindWindowExW");
        child1 = ic.executeCall(new Object[]{
                parent, 0,"SHELLDLL_DefView", null});
        ic.destroy();

    } catch (Exception e) {
        e.printStackTrace();

    }

    System.out.println(" child1 :"+child1);


    try {
        NativeCall.init();
        IntCall ic = new IntCall("user32.dll", "FindWindowExW");
        child1 = ic.executeCall(new Object[]{
                child1, 0,"SysListView32", null});
        ic.destroy();

    } catch (Exception e) {
        e.printStackTrace();

    }

    System.out.println(" child2 :"+child1);

System.out.println("父级:"+parent);

    try {
        NativeCall.init();
        IntCall ic = new IntCall("user32.dll", "FindWindowA");
         tmp = ic.executeCall(new Object[]{
                  "notepad", "hi.txt - Notepad"});
        ic.destroy();

    } catch (Exception e) {
        e.printStackTrace();

}

the desktop windows is part of ProgMan->SHELLDLL_DefView->SysListView32
instead of directly under program in winxp.

let the following code snippet written in java

try {
NativeCall.init();
IntCall ic = new IntCall("user32.dll", "FindWindowA");
parent = ic.executeCall(new Object[]{
"ProgMan", "Program Manager"});
ic.destroy();

    } catch (Exception e) {
        e.printStackTrace();
    }
    System.out.println(" parent :"+parent);




    try {
        NativeCall.init();
        IntCall ic = new IntCall("user32.dll", "FindWindowExW");
        child1 = ic.executeCall(new Object[]{
                parent, 0,"SHELLDLL_DefView", null});
        ic.destroy();

    } catch (Exception e) {
        e.printStackTrace();

    }

    System.out.println(" child1 :"+child1);


    try {
        NativeCall.init();
        IntCall ic = new IntCall("user32.dll", "FindWindowExW");
        child1 = ic.executeCall(new Object[]{
                child1, 0,"SysListView32", null});
        ic.destroy();

    } catch (Exception e) {
        e.printStackTrace();

    }

    System.out.println(" child2 :"+child1);

System.out.println(" parent :"+parent);

    try {
        NativeCall.init();
        IntCall ic = new IntCall("user32.dll", "FindWindowA");
         tmp = ic.executeCall(new Object[]{
                  "notepad", "hi.txt - Notepad"});
        ic.destroy();

    } catch (Exception e) {
        e.printStackTrace();

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文