Win32:如何通过hWnd隐藏任务栏中的第三方窗口 [英] Win32: How to hide 3rd party windows in taskbar by hWnd

查看:824
本文介绍了Win32:如何通过hWnd隐藏任务栏中的第三方窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在第三方库中隐藏弹出窗口。

I have to hide popup windows in third party library.

我已经用 SetWindowsHookEx ,并且知道所有新创建的hWnd。我听到 HSHELL_WINDOWCREATED 回调并执行以下操作:

I have implemented windows hook stuff with SetWindowsHookEx and know all the newely created hWnd(s). I listen to HSHELL_WINDOWCREATED callback and do the following:

long style= GetWindowLong(hWnd, GWL_STYLE);
style &= ~(WS_VISIBLE);    // this works - window become invisible 

style |= WS_EX_TOOLWINDOW;   // flags don't work - windows remains in taskbar
style &= ~(WS_EX_APPWINDOW); 

SetWindowLong(hWnd, GWL_STYLE, style);      

我在这里做什么错误,隐藏在任务栏中新创建的窗口? c>使用 SetWindowLong 之前,请调用

What I do wrong here to hide newely created windows in task bar?

推荐答案

ShowWindow(hWnd,SW_HIDE),然后调用 SetWindowLong ,然后再次调用 ShowWindow code> ShowWindow(hWnd,SW_SHOW)。所以你的代码看起来像这样:

Before you use SetWindowLong, call ShowWindow(hWnd, SW_HIDE), then call SetWindowLong, then call ShowWindow again like ShowWindow(hWnd, SW_SHOW). So your code will look like this:

long style= GetWindowLong(hWnd, GWL_STYLE);
style &= ~(WS_VISIBLE);    // this works - window become invisible 

style |= WS_EX_TOOLWINDOW;   // flags don't work - windows remains in taskbar
style &= ~(WS_EX_APPWINDOW); 

ShowWindow(hWnd, SW_HIDE); // hide the window
SetWindowLong(hWnd, GWL_STYLE, style); // set the style
ShowWindow(hWnd, SW_SHOW); // show the window for the new style to come into effect
ShowWindow(hWnd, SW_HIDE); // hide the window so we can't see it

这是从 Microsoft网站


为了防止窗口按钮放置在任务栏上,使用WS_EX_TOOLWINDOW扩展样式创建
无主窗口。作为一个
的替代方法,你可以创建一个隐藏的窗口,并使这个隐藏的
窗口的可视窗口的所有者。

To prevent the window button from being placed on the taskbar, create the unowned window with the WS_EX_TOOLWINDOW extended style. As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.

窗口的按钮,只有当
窗口的样式支持可见的任务栏按钮时。如果你想
动态的改变一个窗口的风格为不支持
可见的任务栏按钮,你必须首先隐藏窗口(通过调用
ShowWindow与SW_HIDE),改变窗口样式,然后显示
窗口。

The Shell will remove a window's button from the taskbar only if the window's style supports visible taskbar buttons. If you want to dynamically change a window's style to one that doesn't support visible taskbar buttons, you must hide the window first (by calling ShowWindow with SW_HIDE), change the window style, and then show the window.

这篇关于Win32:如何通过hWnd隐藏任务栏中的第三方窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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