Skip to content

Commit 260a069

Browse files
committed
添加项目文件。
1 parent 2bb31c9 commit 260a069

15 files changed

Lines changed: 1673 additions & 0 deletions

HashTool.slnx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Solution>
2+
<Configurations>
3+
<Platform Name="Any CPU" />
4+
<Platform Name="x64" />
5+
</Configurations>
6+
<Project Path="HashTool/HashTool.vbproj">
7+
<Platform Solution="*|x64" Project="x64" />
8+
</Project>
9+
</Solution>

HashTool/Application.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Application x:Class="HashTool.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
</Application>

HashTool/Application.xaml.vb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Namespace HashTool
2+
3+
Partial Public Class App
4+
Inherits Application
5+
End Class
6+
7+
End Namespace

HashTool/AssemblyInfo.vb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Imports System.Windows
2+
3+
'The ThemeInfo attribute describes where any theme specific and generic resource dictionaries can be found.
4+
'1st parameter: where theme specific resource dictionaries are located
5+
'(used if a resource is not found in the page,
6+
' or application resource dictionaries)
7+
8+
'2nd parameter: where the generic resource dictionary is located
9+
'(used if a resource is not found in the page,
10+
'app, and any theme specific resource dictionaries)
11+
<Assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)>

HashTool/DwmHelper.vb

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
Imports System
2+
Imports System.Runtime.InteropServices
3+
4+
Namespace HashTool
5+
6+
Friend Module DwmHelper
7+
8+
' --- Win11 DWM attributes ---
9+
Private Const DWMWA_WINDOW_CORNER_PREFERENCE As Integer = 33
10+
Private Const DWMWA_BORDER_COLOR As Integer = 34
11+
Private Const DWMWA_SYSTEMBACKDROP_TYPE As Integer = 38
12+
13+
' Corner preference values
14+
Private Const DWMWCP_DEFAULT As Integer = 0
15+
Private Const DWMWCP_DONOTROUND As Integer = 1
16+
Private Const DWMWCP_ROUND As Integer = 2
17+
Private Const DWMWCP_ROUNDSMALL As Integer = 3
18+
19+
' Backdrop types (Win11)
20+
Private Const DWMSBT_MAINWINDOW As Integer = 2 ' Mica
21+
22+
' --- Win10 composition fallback ---
23+
Private Const WCA_ACCENT_POLICY As Integer = 19
24+
Private Const ACCENT_ENABLE_BLURBEHIND As Integer = 3
25+
Private Const ACCENT_ENABLE_ACRYLICBLURBEHIND As Integer = 4
26+
27+
<DllImport("dwmapi.dll")>
28+
Private Function DwmSetWindowAttribute(hwnd As IntPtr, dwAttribute As Integer, ByRef pvAttribute As Integer, cbAttribute As Integer) As Integer
29+
End Function
30+
31+
<StructLayout(LayoutKind.Sequential)>
32+
Private Structure ACCENT_POLICY
33+
Public AccentState As Integer
34+
Public AccentFlags As Integer
35+
Public GradientColor As Integer
36+
Public AnimationId As Integer
37+
End Structure
38+
39+
<StructLayout(LayoutKind.Sequential)>
40+
Private Structure WINDOWCOMPOSITIONATTRIBDATA
41+
Public Attribute As Integer
42+
Public Data As IntPtr
43+
Public SizeOfData As Integer
44+
End Structure
45+
46+
<DllImport("user32.dll")>
47+
Private Function SetWindowCompositionAttribute(hwnd As IntPtr, ByRef data As WINDOWCOMPOSITIONATTRIBDATA) As Integer
48+
End Function
49+
50+
Friend Sub TryEnableBackdrop(hwnd As IntPtr)
51+
' ✅ 关键:先把 Win11 系统“圆角/边框”关掉,保证跨系统一致
52+
TryDisableSystemRounding(hwnd)
53+
TrySetBorderColorTransparent(hwnd)
54+
55+
' Win11: Mica
56+
If TrySetSystemBackdrop(hwnd, DWMSBT_MAINWINDOW) Then Return
57+
58+
' Win10 fallback:先 Acrylic,再 Blur
59+
If Not TrySetAccent(hwnd, ACCENT_ENABLE_ACRYLICBLURBEHIND, &HCCFFFFFF) Then
60+
TrySetAccent(hwnd, ACCENT_ENABLE_BLURBEHIND, 0)
61+
End If
62+
End Sub
63+
64+
Private Sub TryDisableSystemRounding(hwnd As IntPtr)
65+
Try
66+
Dim pref As Integer = DWMWCP_DONOTROUND
67+
DwmSetWindowAttribute(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, pref, Marshal.SizeOf(Of Integer)())
68+
Catch
69+
End Try
70+
End Sub
71+
72+
Private Sub TrySetBorderColorTransparent(hwnd As IntPtr)
73+
Try
74+
' DWMWA_BORDER_COLOR uses COLORREF (0x00BBGGRR). 0 means "default".
75+
' We want fully transparent border — Win11 accepts 0x00000000 as "no visible border" in practice.
76+
Dim color As Integer = 0
77+
DwmSetWindowAttribute(hwnd, DWMWA_BORDER_COLOR, color, Marshal.SizeOf(Of Integer)())
78+
Catch
79+
End Try
80+
End Sub
81+
82+
Private Function TrySetSystemBackdrop(hwnd As IntPtr, backdropType As Integer) As Boolean
83+
Try
84+
Dim hr = DwmSetWindowAttribute(hwnd, DWMWA_SYSTEMBACKDROP_TYPE, backdropType, Marshal.SizeOf(Of Integer)())
85+
Return hr = 0
86+
Catch
87+
Return False
88+
End Try
89+
End Function
90+
91+
Private Function TrySetAccent(hwnd As IntPtr, accentState As Integer, rgba As Integer) As Boolean
92+
Try
93+
Dim policy As New ACCENT_POLICY With {
94+
.AccentState = accentState,
95+
.AccentFlags = 2,
96+
.GradientColor = rgba, ' AABBGGRR
97+
.AnimationId = 0
98+
}
99+
100+
Dim size = Marshal.SizeOf(Of ACCENT_POLICY)()
101+
Dim ptr = Marshal.AllocHGlobal(size)
102+
Marshal.StructureToPtr(policy, ptr, False)
103+
104+
Dim data As New WINDOWCOMPOSITIONATTRIBDATA With {
105+
.Attribute = WCA_ACCENT_POLICY,
106+
.Data = ptr,
107+
.SizeOfData = size
108+
}
109+
110+
Dim ret = SetWindowCompositionAttribute(hwnd, data)
111+
Marshal.FreeHGlobal(ptr)
112+
113+
Return ret <> 0
114+
Catch
115+
Return False
116+
End Try
117+
End Function
118+
119+
End Module
120+
121+
End Namespace

HashTool/HashTool.Core.dll

23 KB
Binary file not shown.

HashTool/HashTool.vbproj

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net10.0-windows10.0.17763.0</TargetFramework>
6+
<RootNamespace></RootNamespace>
7+
<UseWPF>true</UseWPF>
8+
<Platforms>AnyCPU;x64</Platforms>
9+
<ApplicationIcon>favicon.ico</ApplicationIcon>
10+
</PropertyGroup>
11+
12+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
13+
<PlatformTarget>x64</PlatformTarget>
14+
</PropertyGroup>
15+
16+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
17+
<PlatformTarget>x64</PlatformTarget>
18+
</PropertyGroup>
19+
20+
<ItemGroup>
21+
<None Remove="HashTool.Core.dll" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<EmbeddedResource Include="HashTool.Core.dll" />
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<Resource Include="favicon.ico" />
30+
</ItemGroup>
31+
32+
<ItemGroup>
33+
<Import Include="System.Windows" />
34+
<Import Include="System.Windows.Controls" />
35+
<Import Include="System.Windows.Data" />
36+
<Import Include="System.Windows.Documents" />
37+
<Import Include="System.Windows.Input" />
38+
<Import Include="System.Windows.Media" />
39+
<Import Include="System.Windows.Media.Imaging" />
40+
<Import Include="System.Windows.Navigation" />
41+
<Import Include="System.Windows.Shapes" />
42+
</ItemGroup>
43+
44+
</Project>

0 commit comments

Comments
 (0)