隐藏/显示 Windows 任务栏

17 篇文章 0 订阅

很多底层操作的函数,Visual Studio 2005.NET 的 API 库中并没有提供,这个时候,我                                                

们就要在 C#开发中调用 Win32 的函数来进行相应的操作。一大批 Win32 底层操作的函数

都存在于 cordll.dll 动态链接库中。

调用 Win32 的申明:

using System.Runtime.InteropServices; 

很多客户的应用程序需要独占屏幕,而不需要下方的 Windows 任务栏。因此显示/隐藏

Windows 任 务 栏 是 一 个 很 实 用 的 功 能 。 这 个 时 候 就 需 要 调 用 coredll.dll 里 的

FindWindow( … )和 ShowWindow( … )函数来实现任务栏的显示和隐藏(Windows 的任务

栏实际上也是一个特殊的 Windows 窗口)。

[DllImport("coredll.dll", EntryPoint = "FindWindow")] 

public static extern int FindWindow( string lpWindowName, string lpClassName ); 

[DllImport("coredll.dll", EntryPoint = "ShowWindow")] 

public static extern int ShowWindow( int hwnd, int nCmdShow ); 

public const int SW_SHOW = 5;   //显示窗口常量

public const int SW_HIDE = 0;     //隐藏窗口常量

下面是一个隐藏/显示 Windows 任务栏的小例子:

                public  Form1() 

                { 

            InitializeComponent(); 

                } 

        private void button1_Click(object sender, EventArgs e) 

                { 

            int Hwnd = FindWindow("HHTaskBar", null); 

                        if  (Hwnd  !=  0) 

                        { 

                ShowWindow(Hwnd, SW_HIDE);   //隐藏任务栏

                button2.Enabled = true; 

                button1.Enabled = false; 

                        } 

                }

        private void button2_Click(object sender, EventArgs e) 

                { 

            int Hwnd = FindWindow("HHTaskBar", null); 

                        if  (Hwnd  !=  0) 

                        { 

                ShowWindow(Hwnd, SW_SHOW);   //显示任务栏

                button1.Enabled = true; 

                button2.Enabled = false; 

                        } 

                }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值