Move drop shadow helper

This commit is contained in:
Nguyen Duy
2024-05-09 07:11:34 +07:00
parent 66ded645d1
commit 38a6b07f2e
4 changed files with 31 additions and 40 deletions
+30
View File
@@ -75,5 +75,35 @@ namespace ParsecVDisplay
[DllImport("kernel32.dll")]
static extern int SetThreadExecutionState(uint esFlags);
public static void EnableDropShadow(IntPtr hwnd)
{
var v = 2;
DwmSetWindowAttribute(hwnd, 2, ref v, 4);
var margins = new MARGINS
{
bottomHeight = 0,
leftWidth = 0,
rightWidth = 0,
topHeight = 1
};
DwmExtendFrameIntoClientArea(hwnd, ref margins);
}
[DllImport("dwmapi.dll")]
static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
[StructLayout(LayoutKind.Sequential)]
struct MARGINS
{
public int leftWidth;
public int rightWidth;
public int topHeight;
public int bottomHeight;
}
[DllImport("dwmapi.dll")]
static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
}
}
+1 -1
View File
@@ -38,7 +38,7 @@ namespace ParsecVDisplay
base.OnSourceInitialized(e);
var hwnd = new WindowInteropHelper(this).EnsureHandle();
Shadow.ApplyShadow(hwnd);
Helper.EnableDropShadow(hwnd);
}
protected override void OnClosing(CancelEventArgs e)
-1
View File
@@ -86,7 +86,6 @@
<Compile Include="Device.cs" />
<Compile Include="Display.cs" />
<Compile Include="Helper.cs" />
<Compile Include="Shadow.cs" />
<Compile Include="Tray.cs" />
<Compile Include="ParsecVDD.cs" />
<Compile Include="Updater.cs" />
-38
View File
@@ -1,38 +0,0 @@
using System;
using System.Runtime.InteropServices;
namespace ParsecVDisplay
{
internal static class Shadow
{
[DllImport("dwmapi.dll")]
static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
[StructLayout(LayoutKind.Sequential)]
struct MARGINS
{
public int leftWidth;
public int rightWidth;
public int topHeight;
public int bottomHeight;
}
[DllImport("dwmapi.dll")]
static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
public static void ApplyShadow(IntPtr hwnd)
{
var v = 2;
DwmSetWindowAttribute(hwnd, 2, ref v, 4);
var margins = new MARGINS
{
bottomHeight = 0,
leftWidth = 0,
rightWidth = 0,
topHeight = 1
};
DwmExtendFrameIntoClientArea(hwnd, ref margins);
}
}
}