Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Runtime.InteropServices;
- public class TransparentTaskbar {
- static class Interop {
- [DllImport("user32.dll", SetLastError = true)]
- internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
- [DllImport("user32.dll")]
- internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
- [StructLayout(LayoutKind.Sequential)]
- internal struct WindowCompositionAttributeData {
- public WindowCompositionAttribute Attribute;
- public IntPtr Data;
- public int SizeOfData;
- }
- [StructLayout(LayoutKind.Sequential)]
- internal struct AccentPolicy {
- public AccentState AccentState;
- public AccentFlags AccentFlags;
- public uint GradientColor;
- public int AnimationId;
- }
- [Flags]
- internal enum AccentFlags {
- // ...
- DrawLeftBorder = 0x20,
- DrawTopBorder = 0x40,
- DrawRightBorder = 0x80,
- DrawBottomBorder = 0x100,
- DrawAllBorders = (DrawLeftBorder | DrawTopBorder | DrawRightBorder | DrawBottomBorder)
- // ...
- }
- internal enum WindowCompositionAttribute {
- // ...
- WCA_ACCENT_POLICY = 19
- // ...
- }
- internal enum AccentState {
- ACCENT_DISABLED = 0,
- ACCENT_ENABLE_GRADIENT = 1,
- ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
- ACCENT_ENABLE_BLURBEHIND = 3,
- ACCENT_INVALID_STATE = 4
- }
- }
- public static void Main(string[] CommandLine) {
- var accent = new Interop.AccentPolicy();
- accent.AccentState = Interop.AccentState.ACCENT_ENABLE_BLURBEHIND;
- var accentPtr = Marshal.AllocHGlobal(Marshal.SizeOf(accent));
- Marshal.StructureToPtr(accent, accentPtr, false);
- var data = new Interop.WindowCompositionAttributeData();
- data.Attribute = Interop.WindowCompositionAttribute.WCA_ACCENT_POLICY;
- data.SizeOfData = Marshal.SizeOf(accent);
- data.Data = accentPtr;
- Interop.SetWindowCompositionAttribute(Interop.FindWindow("Shell_TrayWnd", null), ref data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment