// This Source Code is partially based on reverse engineering of the Windows Operating System, // and is intended for use on Windows systems only. // This Source Code is partially based on the source code provided by the .NET Foundation. // // NOTE: // I split unmanaged code stuff into the NativeMethods library. // If you have suggestions for the code below, please submit your changes there. // https://github.com/lepoco/nativemethods // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming #pragma warning disable SA1307 // Accessible fields should begin with upper-case letter #pragma warning disable CA1060 // Move pinvokes to native methods class using System.Runtime.InteropServices; namespace WPFluent.Interop; /// /// Exposes methods that enumerate the contents of a view and receive notification from callback upon enumeration /// completion. /// internal static class ShObjIdl { /// /// THUMBBUTTON flags. THBF_* /// [Flags] public enum THUMBBUTTONFLAGS { THBF_ENABLED = 0, THBF_DISABLED = 0x1, THBF_DISMISSONCLICK = 0x2, THBF_NOBACKGROUND = 0x4, THBF_HIDDEN = 0x8, THBF_NONINTERACTIVE = 0x10, } /// /// THUMBBUTTON mask. THB_* /// [Flags] public enum THUMBBUTTONMASK { THB_BITMAP = 0x1, THB_ICON = 0x2, THB_TOOLTIP = 0x4, THB_FLAGS = 0x8, } /// /// TBPF_* /// [Flags] public enum TBPFLAG { TBPF_NOPROGRESS = 0, TBPF_INDETERMINATE = 0x1, TBPF_NORMAL = 0x2, TBPF_ERROR = 0x4, TBPF_PAUSED = 0x8, } /// /// STPF_* /// [Flags] public enum STPFLAG { STPF_NONE = 0, STPF_USEAPPTHUMBNAILALWAYS = 0x1, STPF_USEAPPTHUMBNAILWHENACTIVE = 0x2, STPF_USEAPPPEEKALWAYS = 0x4, STPF_USEAPPPEEKWHENACTIVE = 0x8, } /// /// EBO_* /// public enum EXPLORER_BROWSER_OPTIONS { EBO_NONE = 0, EBO_NAVIGATEONCE = 0x1, EBO_SHOWFRAMES = 0x2, EBO_ALWAYSNAVIGATE = 0x4, EBO_NOTRAVELLOG = 0x8, EBO_NOWRAPPERWINDOW = 0x10, EBO_HTMLSHAREPOINTVIEW = 0x20, EBO_NOBORDER = 0x40, EBO_NOPERSISTVIEWSTATE = 0x80, } /// /// EBF_* /// public enum EXPLORER_BROWSER_FILL_FLAGS { EBF_NONE = 0, EBF_SELECTFROMDATAOBJECT = 0x100, EBF_NODROPTARGET = 0x200, } /// /// THUMBBUTTON /// [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Unicode)] public struct THUMBBUTTON { public THUMBBUTTONMASK dwMask; public uint iId; public uint iBitmap; public IntPtr hIcon; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)] public string szTip; public THUMBBUTTONFLAGS dwFlags; /// /// WPARAM value for a THUMBBUTTON being clicked. /// public const int THBN_CLICKED = 0x1800; } /// /// Class DECLSPEC_UUID("56FDF344-FD6D-11d0-958A-006097C9A090") /// [Guid("56FDF344-FD6D-11d0-958A-006097C9A090")] [ClassInterface(ClassInterfaceType.None)] [ComImport] public class CTaskbarList { } /// /// Class DECLSPEC_UUID("9ac9fbe1-e0a2-4ad6-b4ee-e212013ea917") /// [Guid("9ac9fbe1-e0a2-4ad6-b4ee-e212013ea917")] [ClassInterface(ClassInterfaceType.None)] [ComImport] public class ShellItem { } /// /// MIDL_INTERFACE("c43dc798-95d1-4bea-9030-bb99e2983a1a") ITaskbarList4 : public ITaskbarList3 /// [ComImport] [Guid("c43dc798-95d1-4bea-9030-bb99e2983a1a")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITaskbarList4 { // ITaskbarList [PreserveSig] void HrInit(); [PreserveSig] void AddTab(IntPtr hwnd); [PreserveSig] void DeleteTab(IntPtr hwnd); [PreserveSig] void ActivateTab(IntPtr hwnd); [PreserveSig] void SetActiveAlt(IntPtr hwnd); // ITaskbarList2 [PreserveSig] void MarkFullscreenWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.Bool)] bool fFullscreen); // ITaskbarList3 [PreserveSig] void SetProgressValue(IntPtr hwnd, ulong ullCompleted, ulong ullTotal); [PreserveSig] void SetProgressState(IntPtr hwnd, TBPFLAG tbpFlags); [PreserveSig] void RegisterTab(IntPtr hwndTab, IntPtr hwndMDI); [PreserveSig] void UnregisterTab(IntPtr hwndTab); [PreserveSig] void SetTabOrder(IntPtr hwndTab, IntPtr hwndInsertBefore); [PreserveSig] void SetTabActive(IntPtr hwndTab, IntPtr hwndInsertBefore, uint dwReserved); /// /// Adds thumbnail toolbar buttons to the specified window. /// /// Window handle. /// Number of buttons. /// Array of buttons. /// HRESULT [PreserveSig] int ThumbBarAddButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray)] THUMBBUTTON[] pButtons); /// /// Updates thumbnail toolbar buttons for the specified window. /// /// Window handle. /// Number of buttons. /// Array of buttons to update. /// HRESULT [PreserveSig] int ThumbBarUpdateButtons(IntPtr hwnd, uint cButtons, [MarshalAs(UnmanagedType.LPArray)] THUMBBUTTON[] pButtons); [PreserveSig] void ThumbBarSetImageList(IntPtr hWnd, IntPtr himl); [PreserveSig] void SetOverlayIcon(IntPtr hwnd, IntPtr hIcon, [MarshalAs(UnmanagedType.LPWStr)] string pszDescription); [PreserveSig] void SetThumbnailTooltip(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pszTip); [PreserveSig] void SetThumbnailClip(IntPtr hwnd, IntPtr prcClip); // ITaskbarList4 void SetTabProperties(IntPtr hwndTab, STPFLAG stpFlags); } } #pragma warning restore SA1307 // Accessible fields should begin with upper-case letter #pragma warning restore CA1060 // Move pinvokes to native methods class