Skip to content

Commit

Permalink
Move drop shadow helper
Browse files Browse the repository at this point in the history
  • Loading branch information
nomi-san committed May 9, 2024
1 parent 66ded64 commit 38a6b07
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 40 deletions.
30 changes: 30 additions & 0 deletions app/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,35 @@ public static void StayAwake(bool enable)

[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);
}
}
2 changes: 1 addition & 1 deletion app/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected override void OnSourceInitialized(EventArgs e)
base.OnSourceInitialized(e);

var hwnd = new WindowInteropHelper(this).EnsureHandle();
Shadow.ApplyShadow(hwnd);
Helper.EnableDropShadow(hwnd);
}

protected override void OnClosing(CancelEventArgs e)
Expand Down
1 change: 0 additions & 1 deletion app/ParsecVDisplay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
38 changes: 0 additions & 38 deletions app/Shadow.cs

This file was deleted.

0 comments on commit 38a6b07

Please sign in to comment.