Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ManagedShell.AppBar/FullScreenHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void updateFullScreenWindows()
else
{
// Still full screen but no longer active
if (((int)GetWindowLongPtr(hWnd, WindowLongFlags.GWL_EXSTYLE) & (int)ExtendedWindowStyles.WS_EX_TOPMOST) == (int)ExtendedWindowStyles.WS_EX_TOPMOST)
if ((GetWindowLong(hWnd, WindowLongFlags.GWL_EXSTYLE) & (int)ExtendedWindowStyles.WS_EX_TOPMOST) == (int)ExtendedWindowStyles.WS_EX_TOPMOST)
{
// If the new foreground window is a topmost window, don't consider this full-screen app inactive
continue;
Expand Down Expand Up @@ -264,8 +264,8 @@ private FullScreenApp getFullScreenApp(IntPtr hWnd, bool fromTasksService = fals
}

private Rect GetEffectiveWindowRect(IntPtr hWnd)
{
int style = (int)GetWindowLongPtr(hWnd, WindowLongFlags.GWL_STYLE);
{
int style = GetWindowLong(hWnd, WindowLongFlags.GWL_STYLE);
Rect rect;

if ((((int)WindowStyles.WS_CAPTION | (int)WindowStyles.WS_THICKFRAME) & style) == ((int)WindowStyles.WS_CAPTION | (int)WindowStyles.WS_THICKFRAME) ||
Expand Down
6 changes: 3 additions & 3 deletions src/ManagedShell.Common/Helpers/WindowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static IntPtr GetLowestDesktopChildHwnd()

public static void HideWindowFromTasks(IntPtr hWnd)
{
int style = (int)GetWindowLongPtr(hWnd, WindowLongFlags.GWL_EXSTYLE) & ~(int)ExtendedWindowStyles.WS_EX_APPWINDOW;
int style = GetWindowLong(hWnd, WindowLongFlags.GWL_EXSTYLE) & ~(int)ExtendedWindowStyles.WS_EX_APPWINDOW;
if (EnvironmentHelper.IsWindows11OrBetter)
{
// If the window has a Hidden Window owner, set the owner as a tool window instead so that we still receive WM_DPICHANGED on Windows 11.
Expand All @@ -121,15 +121,15 @@ public static void HideWindowFromTasks(IntPtr hWnd)
GetWindowText(hwndOwner, titleBuilder, TITLE_LENGTH + 1);
if (titleBuilder.ToString() == "Hidden Window")
{
SetWindowLongPtr(hwndOwner, WindowLongFlags.GWL_EXSTYLE, (IntPtr)((int)GetWindowLongPtr(hwndOwner, WindowLongFlags.GWL_EXSTYLE) | (int)ExtendedWindowStyles.WS_EX_TOOLWINDOW));
SetWindowLong(hwndOwner, WindowLongFlags.GWL_EXSTYLE, (int)GetWindowLongPtr(hwndOwner, WindowLongFlags.GWL_EXSTYLE) | (int)ExtendedWindowStyles.WS_EX_TOOLWINDOW);
}
}
}
else
{
style |= (int)ExtendedWindowStyles.WS_EX_TOOLWINDOW;
}
SetWindowLongPtr(hWnd, WindowLongFlags.GWL_EXSTYLE, (IntPtr)style);
SetWindowLong(hWnd, WindowLongFlags.GWL_EXSTYLE, style);

ExcludeWindowFromPeek(hWnd);
}
Expand Down
6 changes: 3 additions & 3 deletions src/ManagedShell.Common/SupportingClasses/ShellWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public ShellWindow()

CreateHandle(cp);
MessageReceived += ShellWndProc;
NativeMethods.SetWindowLongPtr(Handle, NativeMethods.WindowLongFlags.GWL_EXSTYLE,
(IntPtr)((int)NativeMethods.GetWindowLongPtr(Handle, NativeMethods.WindowLongFlags.GWL_EXSTYLE) &
~(int)NativeMethods.ExtendedWindowStyles.WS_EX_NOACTIVATE));
NativeMethods.SetWindowLong(Handle, NativeMethods.WindowLongFlags.GWL_EXSTYLE,
NativeMethods.GetWindowLong(Handle, NativeMethods.WindowLongFlags.GWL_EXSTYLE) &
~(int)NativeMethods.ExtendedWindowStyles.WS_EX_NOACTIVATE);

if (NativeMethods.SetShellWindow(Handle) == 1)
{
Expand Down
10 changes: 10 additions & 0 deletions src/ManagedShell.Interop/NativeMethods.User32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ public enum MinimizedMetricsArrangement
[DllImport(User32_DllName, EntryPoint = "GetWindowLongPtr", SetLastError = true)]
private static extern IntPtr GetWindowLong64(IntPtr hWnd, int nIndex);

public static int GetWindowLong(IntPtr hWnd, WindowLongFlags nIndex)
{
return GetWindowLong(hWnd, (int)nIndex);
}

public static IntPtr GetWindowLongPtr(IntPtr hWnd, WindowLongFlags nIndex)
{
return GetWindowLongPtr(hWnd, (int)nIndex);
Expand Down Expand Up @@ -1738,6 +1743,11 @@ public enum WindowShowStyle : uint
[DllImport(User32_DllName, EntryPoint = "SetWindowLongPtr")]
private static extern IntPtr SetWindowLong64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);

public static int SetWindowLong(IntPtr hWnd, WindowLongFlags nIndex, int dwNewLong)
{
return SetWindowLong(hWnd, (int)nIndex, dwNewLong);
}

public static IntPtr SetWindowLongPtr(IntPtr hWnd, WindowLongFlags nIndex, IntPtr dwNewLong)
{
return SetWindowLongPtr(hWnd, (int)nIndex, dwNewLong);
Expand Down
4 changes: 2 additions & 2 deletions src/ManagedShell.WindowsTasks/ApplicationWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,15 @@ public int WindowStyles
{
get
{
return (int)NativeMethods.GetWindowLongPtr(Handle, NativeMethods.WindowLongFlags.GWL_STYLE);
return NativeMethods.GetWindowLong(Handle, NativeMethods.WindowLongFlags.GWL_STYLE);
}
}

public int ExtendedWindowStyles
{
get
{
return (int)NativeMethods.GetWindowLongPtr(Handle, NativeMethods.WindowLongFlags.GWL_EXSTYLE);
return NativeMethods.GetWindowLong(Handle, NativeMethods.WindowLongFlags.GWL_EXSTYLE);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/ManagedShell.WindowsTray/TrayService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ private IntPtr WndProc(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam)

if ((wndPos.flags & SetWindowPosFlags.SWP_SHOWWINDOW) != 0)
{
SetWindowLongPtr(HwndTray, WindowLongFlags.GWL_STYLE,
(IntPtr)((int)GetWindowLongPtr(HwndTray, WindowLongFlags.GWL_STYLE) &
~(int)WindowStyles.WS_VISIBLE));
SetWindowLong(HwndTray, WindowLongFlags.GWL_STYLE,
GetWindowLong(HwndTray, WindowLongFlags.GWL_STYLE) &
~(int)WindowStyles.WS_VISIBLE);

ShellLogger.Debug($"TrayService: {TrayWndClass} became visible; hiding");
}
Expand Down