mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
Compare commits
9 Commits
1.7.11
...
UnsafeCore
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c03ce3486 | ||
|
|
83e187ea9e | ||
|
|
d86232f413 | ||
|
|
4e6691ac51 | ||
|
|
84ad39b192 | ||
|
|
ce50fc41e0 | ||
|
|
1d71048f56 | ||
|
|
08cf823156 | ||
|
|
cca65635a6 |
37
src/Snap.Hutao/Snap.Hutao.Win32/UnsafePInvoke.cs
Normal file
37
src/Snap.Hutao/Snap.Hutao.Win32/UnsafePInvoke.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Windows.UI.Core;
|
||||||
|
using Windows.Win32.Foundation;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.Win32;
|
||||||
|
|
||||||
|
internal static class UnsafePInvoke
|
||||||
|
{
|
||||||
|
private enum WINDOW_TYPE : uint
|
||||||
|
{
|
||||||
|
IMMERSIVE_BODY,
|
||||||
|
IMMERSIVE_DOCK,
|
||||||
|
IMMERSIVE_HOSTED,
|
||||||
|
IMMERSIVE_TEST,
|
||||||
|
IMMERSIVE_BODY_ACTIVE,
|
||||||
|
IMMERSIVE_DOCK_ACTIVE,
|
||||||
|
NOT_IMMERSIVE,
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("Windows.UI.dll", CharSet = CharSet.None, EntryPoint = "#1500", ExactSpelling = false, SetLastError = true)]
|
||||||
|
[DefaultDllImportSearchPaths(DllImportSearchPath.System32)]
|
||||||
|
private static extern HRESULT PrivateCreateCoreWindow(WINDOW_TYPE WindowType, PWSTR pWindowTitle, int x, int y, uint uWidth, uint uHeight, uint dwAttributes, HWND hOwnerWindow, Guid riid, out nint ppv);
|
||||||
|
|
||||||
|
public static unsafe CoreWindow PrivateCreateCoreWindow(string title, HWND hOwnerWindow)
|
||||||
|
{
|
||||||
|
fixed(char* pTitle = title)
|
||||||
|
{
|
||||||
|
PrivateCreateCoreWindow(WINDOW_TYPE.NOT_IMMERSIVE, pTitle, 0, 0, 400, 400, 0, hOwnerWindow, typeof(ICoreWindow).GUID, out nint thisPtr);
|
||||||
|
return CoreWindow.FromAbi(thisPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,9 +8,11 @@ using Microsoft.UI.Xaml;
|
|||||||
using Microsoft.UI.Xaml.Media;
|
using Microsoft.UI.Xaml.Media;
|
||||||
using Snap.Hutao.Core.Setting;
|
using Snap.Hutao.Core.Setting;
|
||||||
using Snap.Hutao.Service;
|
using Snap.Hutao.Service;
|
||||||
|
using Snap.Hutao.Win32;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Windows.Graphics;
|
using Windows.Graphics;
|
||||||
using Windows.UI;
|
using Windows.UI;
|
||||||
|
using Windows.UI.Core;
|
||||||
using Windows.Win32.Foundation;
|
using Windows.Win32.Foundation;
|
||||||
using Windows.Win32.Graphics.Dwm;
|
using Windows.Win32.Graphics.Dwm;
|
||||||
using Windows.Win32.UI.WindowsAndMessaging;
|
using Windows.Win32.UI.WindowsAndMessaging;
|
||||||
@@ -55,6 +57,7 @@ internal sealed class WindowController
|
|||||||
ExtendsContentIntoTitleBar();
|
ExtendsContentIntoTitleBar();
|
||||||
|
|
||||||
RecoverOrInitWindowSize();
|
RecoverOrInitWindowSize();
|
||||||
|
CoreWindow coreWindow = UnsafePInvoke.PrivateCreateCoreWindow("Snap Hutao CoreWindow", options.Hwnd);
|
||||||
UpdateImmersiveDarkMode(options.TitleBar, default!);
|
UpdateImmersiveDarkMode(options.TitleBar, default!);
|
||||||
|
|
||||||
// appWindow.Show(true);
|
// appWindow.Show(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user