如何隐藏/显示任务栏? [英] How can I Hide/Show Taskbar?

查看:829
本文介绍了如何隐藏/显示任务栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



Hi everyone,

private static void SetVisibility(bool show)
        {
            // get taskbar window
            IntPtr taskBarWnd = FindWindow("Shell_TrayWnd", null);

            // try it the WinXP way first...
            IntPtr startWnd = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start");
            if (startWnd == IntPtr.Zero)
            {
                // ok, let's try the Vista easy way...
                startWnd = FindWindow("Button", null);

                if (startWnd == IntPtr.Zero)
                {
                    // no chance, we need to to it the hard way...
                    startWnd = GetVistaStartMenuWnd(taskBarWnd);
                }
            }

            ShowWindow(taskBarWnd, show ? SW_SHOW : SW_HIDE);
            ShowWindow(startWnd, show ? SW_SHOW : SW_HIDE);
        }





使用该功能,我可以隐藏任务栏,但它不再显示。

对于隐藏任务栏我正在使用Form DeActive Event,而对于Show Taskbar我正在使用Form_Closing Event。但它不起作用..



有什么问题?我该如何解决?



感谢您的回答,祝您有个美好的一天......



With that function, I can hide Taskbar, but it isn't showing again.
For Hide Taskbar I'm using Form DeActive Event, and for Show Taskbar I'm using Form_Closing Event. But it is not work..

What is the problem? How can I solve?

Thanks for answers, have a good day...

推荐答案

Long我曾经使用过.net Forms,但是我记得有一个内置的选项可以在任务栏中显示/隐藏windown,例如: this.ShowInTaskbar = false;



因为你已经进入WinAPI了。如果需要,我强烈建议加倍思考和研究。如果你仍然认为winapi是最好的方法,请阅读: https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx [ ^ ]你想这样做应该可以解决问题:

Long time I used .net Forms, but as I remember there was an built in option to show/hide windown in taskbar somethink like: this.ShowInTaskbar = false;

As you already got into WinAPI for doing that. I strongly suggest to double think and research if it's needed. If you still think winapi is the best approach, read this: https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx[^] you somethink like this should do the trick:
SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_APPWINDOW);

SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) & ~WS_EX_APPWINDOW);



想法是获取当前窗口样式并添加或删除所需的标志(还可以阅读有关按位操作以及添加/删除标志的方式)。


The idea is to get the current window style and add or remove flags you want (also read about bitwise operations and how adding/removing flags works).


这篇关于如何隐藏/显示任务栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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