Skip to content

Commit 52a03d6

Browse files
committed
Update
1 parent 4bdcdfa commit 52a03d6

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

Diff for: src/Files.App/ViewModels/UserControls/Previews/ShellPreviewViewModel.cs

+10-19
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
using Windows.Win32.Graphics.Dxgi;
1414
using Windows.Win32.Graphics.DirectComposition;
1515
using Windows.Win32.Graphics.Dwm;
16-
using Windows.Win32.System.Registry;
1716
using Windows.Win32.UI.Shell;
1817
using Windows.Win32.UI.WindowsAndMessaging;
1918
using WinRT;
@@ -26,10 +25,6 @@ namespace Files.App.ViewModels.Previews
2625
{
2726
public sealed class ShellPreviewViewModel : BasePreviewModel
2827
{
29-
private static readonly Guid IPreviewHandlerIid = new(0x8895b1c6, 0xb41f, 0x4c1c, 0xa5, 0x62, 0x0d, 0x56, 0x42, 0x50, 0x83, 0x6f);
30-
private static readonly Guid QueryAssociationsClsid = new(0xa07034fd, 0x6caa, 0x4954, 0xac, 0x3f, 0x97, 0xa2, 0x72, 0x16, 0xf9, 0x8a);
31-
private static readonly Guid IQueryAssociationsIid = new(0xc46ca590, 0x3c3f, 0x11d2, 0xbe, 0xe6, 0x00, 0x00, 0xf8, 0x05, 0xca, 0x57);
32-
3328
PreviewHandler? currentHandler;
3429
ContentExternalOutputLink? outputLink;
3530
WNDCLASSEXW? wCls;
@@ -108,9 +103,10 @@ private unsafe LRESULT WndProc(HWND hwnd, uint msg, WPARAM wParam, LPARAM lParam
108103
var clsid = FindPreviewHandlerFor(Item.FileExtension, hwnd.Value);
109104

110105
isOfficePreview = new Guid?[] {
111-
Guid.Parse("84F66100-FF7C-4fb4-B0C0-02CD7FB668FE"),
106+
Guid.Parse("84F66100-FF7C-4fb4-B0C0-02CD7FB668FE"), //
112107
Guid.Parse("65235197-874B-4A07-BDC5-E65EA825B718"),
113-
Guid.Parse("00020827-0000-0000-C000-000000000046") }.Contains(clsid);
108+
Guid.Parse("00020827-0000-0000-C000-000000000046")
109+
}.Contains(clsid);
114110

115111
try
116112
{
@@ -138,21 +134,18 @@ private unsafe LRESULT WndProc(HWND hwnd, uint msg, WPARAM wParam, LPARAM lParam
138134
public unsafe void LoadPreview(UIElement presenter)
139135
{
140136
var parent = MainWindow.Instance.WindowHandle;
137+
var hInst = PInvoke.GetModuleHandle(default(PWSTR));
138+
var szClassName = $"{GetType().Name}-{Guid.NewGuid()}";
139+
var szWindowName = $"Preview";
141140

142-
HINSTANCE hInst = PInvoke.GetModuleHandle(default(PWSTR));
143-
144-
string className = $"{GetType().Name}{Guid.NewGuid()}";
145-
146-
fixed (char* pszClassName = className)
141+
fixed (char* pszClassName = szClassName)
147142
{
148-
PWSTR pwszClassName = new(pszClassName);
149-
150143
wCls = new WNDCLASSEXW
151144
{
152145
cbSize = (uint)Marshal.SizeOf(typeof(WNDCLASSEXW)),
153146
lpfnWndProc = new(WndProc),
154147
hInstance = hInst,
155-
lpszClassName = pwszClassName,
148+
lpszClassName = pszClassName,
156149
style = 0,
157150
hIcon = default,
158151
hIconSm = default,
@@ -163,14 +156,12 @@ public unsafe void LoadPreview(UIElement presenter)
163156
cbWndExtra = 0,
164157
};
165158

166-
fixed (char* pszWindowName = "Preview")
159+
fixed (char* pszWindowName = szWindowName)
167160
{
168-
PWSTR lpwszWindowName = new(pszWindowName);
169-
170161
hwnd = PInvoke.CreateWindowEx(
171162
WINDOW_EX_STYLE.WS_EX_LAYERED | WINDOW_EX_STYLE.WS_EX_COMPOSITED,
172163
wCls.Value.lpszClassName,
173-
lpwszWindowName,
164+
pszWindowName,
174165
WINDOW_STYLE.WS_CHILD | WINDOW_STYLE.WS_CLIPSIBLINGS | WINDOW_STYLE.WS_VISIBLE,
175166
0, 0, 0, 0,
176167
new(parent),

0 commit comments

Comments
 (0)