- [DEVEXPRESS] Chia sẻ source code cách tạo biểu đồ sơ đồ tổ chức công ty Org Chart trên Winform C#
- [C#] Hướng dẫn tạo Auto Number trên Datagridview winform
- [DATABASE] Hướng dẫn tạo Procedure String Split in Mysql
- [C#] Thiết lập dấu (,) hay dấu (.) ở định dạng số đúng với định dạng số Việt Nam
- [C#] Chia sẻ source code Game Spin Lucky Wheel
- [C#] Hướng dẫn Encode and Decode HTML
- Danh sách tài khoản ChatGPT miễn phí - Hướng dẫn tạo tài khoản Chat Open AI GPT tại Việt Nam
- [C#] Hướng dẫn thay đổi giao diện ứng dụng Winform theo giao diện của Windows
- [VB.NET] Hiệu ứng Acrylic, Mica, Tabbed Blur Effect trên Winform
- [DEVEXPRESS] Hướng dẫn sử dụng HTML Template trên Combobox Edit
- [C#] Chia sẻ source code Orange Rain in Winform
- [DEVEXPRESS] Hướng dẫn sử dụng HTML Template trên XtraMessageBox Winform Devexpress 22.2.3
- [DEVEXPRESS] Hướng dẫn sử dụng HTML and CSS Code Viewer trên Winform
- [C#] Number Effect Counter up and down in winform
- [C#] Hướng dẫn Supend and Resume Process ID in Winform
- [C#] Hiển thị line number trên Richtextbox Winform
- [C#] Fake Blue Screen BSOD in winform
- [C#] Chia sẽ code demo sử dụng Async Parallel Foreach and For in Winform
- [C#] Sử dụng ActionBlock run X task at time winform
- [C#] Hướng dẫn sử dụng Property Grid để lưu và tải lại thông tin cấu hình user trên winform
[VB.NET] Hiệu ứng Acrylic, Mica, Tabbed Blur Effect trên Winform
Xin chào các bạn, bài viết hôm nay mình tiếp tục hướng dẫn các bạn tạo hiệu ứng Blur Effect Acrylic, Mica and Tabbed của Windows 11 trên Winform bằng ngồn ngữ VB.NET
[VB.NET] How to Blur Effect Acrylic, Mica, Tabbed Windows 11
Giao diện demo ứng dụng:
Ở màn hình này, các bạn có thể chọn giao diện Theme Dark/Light ở nút button.
Video demo ứng dụng Blur Effect VB.NET:
Đầu tiên các bạn tạo 1 class Pinvoke.vb
:
Imports System.Runtime.InteropServices
Public Class PInvoke
Public Class ParameterTypes
<Flags>
Public Enum DWMWINDOWATTRIBUTE
DWMWA_USE_IMMERSIVE_DARK_MODE = 20
DWMWA_SYSTEMBACKDROP_TYPE = 38
End Enum
<StructLayout(LayoutKind.Sequential)>
Public Structure MARGINS
Public cxLeftWidth As Integer
Public cxRightWidth As Integer
Public cyTopHeight As Integer
Public cyBottomHeight As Integer
End Structure
End Class
Public Class Methods
<DllImport("DwmApi.dll")>
Public Shared Function DwmExtendFrameIntoClientArea(ByVal hwnd As IntPtr, ByRef pMarInset As ParameterTypes.MARGINS) As Integer
End Function
<DllImport("dwmapi.dll")>
Public Shared Function DwmSetWindowAttribute(ByVal hwnd As IntPtr, ByVal dwAttribute As ParameterTypes.DWMWINDOWATTRIBUTE, ByRef pvAttribute As Integer, ByVal cbAttribute As Integer) As Integer
End Function
Public Shared Function ExtendFrame(ByVal hwnd As IntPtr, ByVal margins As ParameterTypes.MARGINS) As Integer
Return DwmExtendFrameIntoClientArea(hwnd, margins)
End Function
Public Shared Function SetWindowAttribute(ByVal hwnd As IntPtr, ByVal attribute As ParameterTypes.DWMWINDOWATTRIBUTE, ByVal parameter As Integer) As Integer
Return DwmSetWindowAttribute(hwnd, attribute, parameter, Marshal.SizeOf(Of Integer)())
End Function
End Class
End Class
Và tiếp theo là source code cho Form1.vb
Imports System.Net
Imports System.Windows.Interop
Imports AcrylicBlurWindows11.PInvoke.ParameterTypes
Imports AcrylicBlurWindows11.PInvoke.Methods
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim bounds As MARGINS = New MARGINS
Dim hwnd As IntPtr = Handle
With bounds
.cxLeftWidth = 0
.cxRightWidth = 0
.cyTopHeight = Me.Height - 105 'Screen.PrimaryScreen.Bounds.Height - 60
.cyBottomHeight = 0
End With
Dim result As Integer = DwmExtendFrameIntoClientArea(hwnd, bounds)
Me.BackColor = Color.Black
Dim Panel As New Panel
With Panel
.Size = New Size(Me.Width, Me.Height - 60)
.Location = New Point(0, 0)
.Anchor = AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top Or AnchorStyles.Bottom
.BackColor = Color.FromKnownColor(KnownColor.Control)
End With
'Panel.Dock = DockStyle.Fill
' Me.Controls.Add(Panel)
End Sub
Private Sub rdoArcylic_CheckedChanged(sender As Object, e As EventArgs) Handles rdoArcylic.CheckedChanged
If rdoArcylic.Checked Then
SetWindowAttribute(Me.Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3)
End If
End Sub
Private Sub rdoMica_CheckedChanged(sender As Object, e As EventArgs) Handles rdoMica.CheckedChanged
If rdoMica.Checked Then
SetWindowAttribute(Me.Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 2)
End If
End Sub
Private Sub rdoTabbed_CheckedChanged(sender As Object, e As EventArgs) Handles rdoTabbed.CheckedChanged
If rdoTabbed.Checked Then
SetWindowAttribute(Me.Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 4)
End If
End Sub
Private Sub rdoNone_CheckedChanged(sender As Object, e As EventArgs) Handles rdoNone.CheckedChanged
If rdoNone.Checked Then
SetWindowAttribute(Me.Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 1)
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Button1.Tag.ToString() = "0" Then
SetWindowAttribute(
Me.Handle,
DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE,
1)
Button1.Tag = "1"
Button1.Text = "Light"
Else
SetWindowAttribute(
Me.Handle,
DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE,
0)
Button1.Tag = "0"
Button1.Text = "Dark"
End If
End Sub
End Class
Thanks for watching!