显示或隐藏程序任务栏图标

隐藏

::ShowWindow(m_hWnd, SW_HIDE);

 

LONG lStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);

lStyle &= ~WS_EX_APPWINDOW;

lStyle |= WS_EX_TOOLWINDOW;

::SetWindowLong(m_hWnd, GWL_EXSTYLE, lStyle);

 

::ShowWindow(m_hWnd, SW_SHOW);

 

显示

::ShowWindow(m_hWnd, SW_HIDE);

LONG lStyle = ::GetWindowLong(m_hWnd, GWL_EXSTYLE);

lStyle &= ~WS_EX_TOOLWINDOW;

lStyle |= WS_EX_APPWINDOW;

::SetWindowLong(m_hWnd, GWL_EXSTYLE, lStyle);

::ShowWindow(m_hWnd, SW_SHOW);

 

//参考MSDN

Managing Taskbar Buttons

The Shell creates a button on the taskbar whenever an application creates a window that isn't owned. To ensure that the window button is placed on the taskbar, create an unowned window with the WS_EX_APPWINDOW extended style. 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.

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.

The window button typically contains the application icon and title. However, if the application does not contain a system menu, the window button is created without the icon.

If you want your application to get the user's attention when the window is not active, use the FlashWindow function to let the user know that a message is waiting. This function flashes the window button. Once the user clicks the window button to activate the window, your application can display the message.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值