C#显示及隐藏任务栏
//話不多說,//大家互相交流,有不足處請指正
1.Form頁面如下
2.代碼如下
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 顯示隱藏任務欄
{
? ? public partial class Form1 : Form
? ? {
? ? ? ? private const int SW_HIDE = 0; ?//隱藏任務欄
? ? ? ? private const int SW_RESTORE = 9;//顯示任務欄
? ? ? ? [DllImport("user32.dll")]
? ? ? ? public static extern int ShowWindow(int hwnd, int nCmdShow); //此為重點
? ? ? ? [DllImport("user32.dll")]
? ? ? ? public static extern int FindWindow(string lpClassName, string lpWindowName); //此為重點
? ? ? ? public Form1()
? ? ? ? {
? ? ? ? ? ? InitializeComponent();
? ? ? ? }
? ? ? ? private void button1_Show_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? ShowWindow(FindWindow("Shell_TrayWnd", null), SW_RESTORE);
? ? ? ? ? ? if (checkBox1.Checked == true)? //checkBox1選中狀態,click后則控件關閉
? ? ? ? ? ? {
? ? ? ? ? ? ? ? this.Dispose();
? ? ? ? ? ? ? ? this.Close();
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? private void button2_Hide_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? ShowWindow(FindWindow("Shell_TrayWnd", null), SW_HIDE);
? ? ? ? ? ? if (checkBox1.Checked == true) //checkBox1為選中狀態時候,click后則控件關閉
? ? ? ? ? ? {
? ? ? ? ? ? ? ? this.Dispose();
? ? ? ? ? ? ? ? this.Close();
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
總結
以上是生活随笔為你收集整理的C#显示及隐藏任务栏的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 高二物竞转北大计算机华师,华师一附中最牛
- 下一篇: mysql n8_mysql几种引擎和使