C# WinForm ShowInTaskbar Api Version

时间:2022-01-23 14:38:21
 using System;
using System.Runtime.InteropServices; namespace x
{
unsafe class NativeWindow
{
/*
* Window field offsets for GetWindowLong()
*/
public const int GWL_WNDPROC = (-);
public const int GWL_HINSTANCE = (-);
public const int GWL_HWNDPARENT = (-);
public const int GWL_STYLE = (-);
public const int GWL_EXSTYLE = (-);
public const int GWL_USERDATA = (-);
public const int GWL_ID = (-); public const int GWLP_WNDPROC = (-);
public const int GWLP_HINSTANCE = (-);
public const int GWLP_HWNDPARENT = (-);
public const int GWLP_USERDATA = (-);
public const int GWLP_ID = (-); /*
* ShowWindow() Commands
*/
public const int SW_HIDE = ;
public const int SW_SHOWNORMAL = ;
public const int SW_NORMAL = ;
public const int SW_SHOWMINIMIZED = ;
public const int SW_SHOWMAXIMIZED = ;
public const int SW_MAXIMIZE = ;
public const int SW_SHOWNOACTIVATE = ;
public const int SW_SHOW = ;
public const int SW_MINIMIZE = ;
public const int SW_SHOWMINNOACTIVE = ;
public const int SW_SHOWNA = ;
public const int SW_RESTORE = ;
public const int SW_SHOWDEFAULT = ;
public const int SW_FORCEMINIMIZE = ;
public const int SW_MAX = ; [DllImport("user32.dll")]
public static extern IntPtr GetTaskmanWindow(); [DllImport("user32.dll")]
public static extern IntPtr SendMessageA(
[In] IntPtr hWnd,
[In] int Msg,
[In] IntPtr wParam,
[In] IntPtr lParam
); [DllImport("user32.dll")]
public static extern int SetWindowLongA(
[In] IntPtr hWnd,
[In] int nIndex,
[In] int dwNewLong
); [DllImport("user32.dll")]
public static extern IntPtr SetWindowLongPtrA(
[In] IntPtr hWnd,
[In] int nIndex,
[In] IntPtr dwNewLong
); [DllImport("user32.dll")]
public static extern bool ShowWindow(
[In] IntPtr hWnd,
[In] int nCmdShow
); private IntPtr _hWnd;
private bool _bShowInTaskbar; public bool ShowInTaskbar
{
get { return _bShowInTaskbar; } set
{
if (value)
{
SetWindowLongCore(_hWnd, GWLP_HWNDPARENT, GetTaskmanWindow());
}
else
{
SetWindowLongCore(_hWnd, GWLP_HWNDPARENT, (IntPtr));
}
SendMessageA(hwndroot, WM_SETREDRAW, (IntPtr), (IntPtr));
ShowWindow(hwndroot, SW_HIDE);
ShowWindow(hwndroot, SW_SHOW);
SendMessageA(hwndroot, WM_SETREDRAW, (IntPtr), (IntPtr));
_bShowInTaskbar = value;
}
} public NativeWindow() { } public static IntPtr SetWindowLongCore(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
{
if (sizeof(void*) == )
{
return (IntPtr)SetWindowLongA(hWnd, nIndex, (int)dwNewLong);
}
return SetWindowLongPtrA(hWnd, nIndex, dwNewLong);
} }
}