mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-09-30 09:06:32 +13:00
Fix 32bit support
This commit is contained in:
parent
27c428602b
commit
6db7226249
1 changed files with 28 additions and 5 deletions
|
@ -26,23 +26,46 @@ namespace SystemTrayMenu.DllImports
|
||||||
{
|
{
|
||||||
WindowInteropHelper wndHelper = new WindowInteropHelper(window);
|
WindowInteropHelper wndHelper = new WindowInteropHelper(window);
|
||||||
|
|
||||||
int exStyle = (int)GetWindowLongPtr(wndHelper.Handle, GWL_EXSTYLE);
|
if (Environment.Is64BitProcess)
|
||||||
exStyle |= WS_EX_TOOLWINDOW; // do not show when user presses alt + tab
|
{
|
||||||
SetWindowLongPtr(wndHelper.Handle, GWL_EXSTYLE, (IntPtr)exStyle);
|
long exStyle = (long)GetWindowLongPtr(wndHelper.Handle, GWL_EXSTYLE);
|
||||||
|
exStyle |= WS_EX_TOOLWINDOW; // do not show when user presses alt + tab
|
||||||
|
SetWindowLongPtr(wndHelper.Handle, GWL_EXSTYLE, (IntPtr)exStyle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int exStyle = (int)GetWindowLong(wndHelper.Handle, GWL_EXSTYLE);
|
||||||
|
exStyle |= WS_EX_TOOLWINDOW; // do not show when user presses alt + tab
|
||||||
|
SetWindowLong(wndHelper.Handle, GWL_EXSTYLE, (IntPtr)exStyle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongw .
|
||||||
|
/// </summary>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
private static extern IntPtr GetWindowLong(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongptrw .
|
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowlongptrw .
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
||||||
private static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);
|
private static extern IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongw .
|
||||||
|
/// </summary>
|
||||||
|
[SupportedOSPlatform("windows")]
|
||||||
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
||||||
|
private static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptrw .
|
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptrw .
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Winapi)]
|
||||||
private static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
private static extern IntPtr SetWindowLongPtr(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue