Skip to content

Commit 81ab8b4

Browse files
committed
Account for taskbar on different display
File-New-Project#1611
1 parent c26b809 commit 81ab8b4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

EarTrumpet/Interop/Helpers/WindowsTaskbar.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Drawing;
23
using System.Diagnostics;
34
using System.Runtime.InteropServices;
45
using System.Windows.Forms;
@@ -43,7 +44,7 @@ public static State Current
4344
var appBarData = new APPBARDATA
4445
{
4546
cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)),
46-
hWnd = hWnd
47+
lParam = 0x42 // magic to get StartAllBack active taskbar rect
4748
};
4849

4950
// SHAppBarMessage: Understands Taskbar auto-hide
@@ -52,6 +53,10 @@ public static State Current
5253
{
5354
state.Size = appBarData.rect;
5455
state.Location = (Position)appBarData.uEdge;
56+
var r = new Rectangle(appBarData.rect.Left, appBarData.rect.Top,
57+
appBarData.rect.Right - appBarData.rect.Left,
58+
appBarData.rect.Bottom - appBarData.rect.Top);
59+
state.ContainingScreen = Screen.FromRectangle(r);
5560
}
5661
else
5762
{

0 commit comments

Comments
 (0)