- [C#] Hướng dẫn fix lỗi Visual Studio 2022 not Support Target Net Framework 4.5.2
- [C#] Giới thiệu thư viện Sunny UI thiết kế giao diện trên Winform
- [DATABASE] Hướng dẫn thêm và cập nhật Extended Property Column trong Table Sqlserver
- [DEVEXPRESS] Hướng dẫn sử dụng Vertical Gridview để hiển thị thông tin sản phẩm
- [C#] Hướng dẫn sử dụng Json Schema để Validate chuỗi string có phải json
- [C#] Hướng dẫn sử dụng công cụ Clean Code trên Visual Studio
- [C#] Hướng dẫn Drag and Drop File vào RichTextBox
- [C#] Hướng dẫn tạo hiệu ứng Karaoke Text Effect Winform
- [C#] Sử dụng thư viện ZedGraph vẽ biểu đồ Line, Bar, Pie trên Winform
- [DATABASE] Hướng dẫn sort sắp xếp địa chỉ IP trên sqlserver sử dụng hàm PARSENAME
- [C#] Theo dõi sử kiện process Start hay Stop trên Winform
- [ASP.NET] Chia sẻ source code chụp hình sử dụng camera trên website
- [C#] Chạy ứng dụng trên Virtual Desktop (màn hình ảo) Winform
- [C#] Mã hóa và giải mã Data Protection API trên winform
- [C#] Hướng dẫn tạo Gradient Background trên Winform
- [DATABASE] Hướng dẫn convert Epoch to DateTime trong sqlserver
- [DATABASE] Hướng dẫn sử dụng STRING_AGG và CONCAT_WS trong sqlserver 2017
- [C#] Hướng dẫn Copy With All Property in Class Object
- [DEVEXPRESS] Hướng dẫn load Json DataSource vào GridView
- [C#] Hướng dẫn tạo chữ ký trên winform Signature Pad
Hướng dẫn tạo hiệu ứng nhấp nháy ứng dụng dưới taskbar (flash and blink in taskbar) VB.NET
Hôm nay, mình xin hướng dẫn các bạn làm hiệu ứng nhấp nháy ứng dụng dưới thanh taskbar (flash and blink)
Ví dụ: bạn nào đã từng dùng Yahoo, các bạn sẽ thấy khi có tin nhắn đến, thì của sổ chat ở dưới taskbar của chúng ta nhấp nháy hình màu cam.
- Đầu tiên, các bạn thiết kế form có giao diện như hình bên dưới:
- Bài viết này rất đơn giản bạn chỉ cần sử dụng hàm API của window
Bước 1: Đầu tiên các bạn tạo một class với tên là WindowApi với nội dung như sau
Public Class WindowsApi
Private Declare Function FlashWindowEx Lib "User32" (ByRef fwInfo As FLASHWINFO) As Boolean
Public Enum FlashWindowFlags As UInt32
' Stop flashing. The system restores the window to its original state.
FLASHW_STOP = 0
' Flash the window caption.
FLASHW_CAPTION = 1
' Flash the taskbar button.
FLASHW_TRAY = 2
' Flash both the window caption and taskbar button.
' This is equivalent to setting the FLASHW_CAPTION | FLASHW_TRAY flags.
FLASHW_ALL = 3
' Flash continuously, until the FLASHW_STOP flag is set.
FLASHW_TIMER = 4
' Flash continuously until the window comes to the foreground.
FLASHW_TIMERNOFG = 12
End Enum
Public Structure FLASHWINFO
Public cbSize As UInt32
Public hwnd As IntPtr
Public dwFlags As FlashWindowFlags
Public uCount As UInt32
Public dwTimeout As UInt32
End Structure
Public Shared Function FlashWindow(ByRef handle As IntPtr, ByVal FlashTitleBar As Boolean, ByVal FlashTray As Boolean, ByVal FlashCount As Integer) As Boolean
If handle = Nothing Then Return False
Try
Dim fwi As New FLASHWINFO
With fwi
.hwnd = handle
If FlashTitleBar Then .dwFlags = .dwFlags Or FlashWindowFlags.FLASHW_CAPTION
If FlashTray Then .dwFlags = .dwFlags Or FlashWindowFlags.FLASHW_TRAY
.uCount = CUInt(FlashCount)
If FlashCount = 0 Then .dwFlags = .dwFlags Or FlashWindowFlags.FLASHW_TIMERNOFG
.dwTimeout = 0 ' Use the default cursor blink rate.
.cbSize = CUInt(System.Runtime.InteropServices.Marshal.SizeOf(fwi))
End With
Return FlashWindowEx(fwi)
Catch
Return False
End Try
End Function
End Class
Bước 2: Viết sự kiện cho nút thực hiện
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim res = WindowsApi.FlashWindow(Process.GetCurrentProcess().MainWindowHandle, True, True, 3)
End Sub
XEM VIDEO DEMO
CHÚC CÁC BẠN THÀNH CÔNG!