- [C#] Viết ứng dụng xem và dò kết quả xổ số kiến thiết miền nam
- [C#] Hướng dẫn viết ứng dụng theo dõi máy in bao nhiêu trang (Monitor Printer)
- [C#] Lấy thông tin cấu hình máy tính xuất ra text file winform
- [C#] Chia sẽ class Install, Uninstall, Start và Stop Services Winform
- [C#] Tìm kiếm tập tin file nhanh chóng trên Winform sử dụng thư viện FastSearchLibrary
- [C#] Giới thiệu thư viện Fluent FTP Awesome dùng để làm việc với FTP
- [C#] Sử dụng thư viện Mini Profiler Integrations ghi log thực hiện các câu lệnh SQL
- [DEVEXPRESS] Thiết kế Dropdown ButtonBarItem trên Form Ribbon
- [C#] Lưu trạng thái các control trên Winform vào Registry Windows
- [C#] Ứng dụng ví dụ Simple Observer Pattern tăng giảm số lượng trên winform
- [C#] Hướng dẫn lấy thời gian thực server time trên winform
- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
- [C#] Flash Window in Taskbar Winform
[C#] Hướng dẫn viết ứng dụng show and hide icon desktop windows
Xin chào các bạn, bài viết hôm nay mình sẽ tiếp tục chia sẽ đến các bạn viết một ứng dụng show và hide icon trên Desktop Windows lập trình C#.
[C#] Show and Hide Icon Desktop
Trên windows, nếu bạn nào đang chứa nhiều tập tin, thư mục và hiển thị người ứng dụng ở desktop, các bạn muốn ẩn tất cả các ứng dụng, thư mục và tập tin đó đi.
Các bạn sẽ thực hiện như sau trên Windows:
Right Click vào Desktop => View => Show Desktop Icon.
Thực hiện như hình ở bên dưới:
Trong bài viết này, mình sẽ hướng dẫn các bạn cách thực hiện chức năng này trong ngôn ngữ lập trình C#.
Giao diện Demo ứng dụng:
Chúng ta chỉ cần thiết kế 2 button Hide Icon và Show Icon để demo chức năng này.
Source code C#:
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 HideShowDesktopIcon
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hwndParent,
IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
private void btn_hide_Click(object sender, EventArgs e)
{
IntPtr hWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Progman", null);
ShowWindow(hWnd, 0);
}
private void btn_show_Click(object sender, EventArgs e)
{
IntPtr hWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Progman", null);
ShowWindow(hWnd, 5);
}
}
}
Thanks For Watching!