Search code examples
c#.netwpfwindows-xpappbar

APPBAR space allocation issue in Windows XP


I create an APPBAR in my WPF application, it is working fine in windows 7, but in XP it has an issue. After i close the application, i expect the space used by APPBAR should be free and reallocated to the desktop, but this does not happens in windows XP. But if i Lock/Unlock the taskbar then it allocate the space back to the system.

Kindly guide me towards some solution to it.


Solution

  •   public static void RemoveAppBar(Window appbarWindow)
            {
                RegisterInfo info = GetRegisterInfo(appbarWindow);
    
                if (info.IsRegistered)
                {
                    APPBARDATA abd = new APPBARDATA();
                    abd.cbSize = Marshal.SizeOf(abd);
                    abd.hWnd = new WindowInteropHelper(appbarWindow).Handle;
                    SHAppBarMessage((int)ABMsg.ABM_REMOVE, ref abd);
                }
            }
    

    Call this method on App.Exit event and pass your appbar window on it.