private Boolean AppbarNew()
        {
            if (CallbackMessageID == 0)
            {
                throw new Exception("CallbackMessageID is 0");
            }

            if (IsAppbarMode)
            {
                return(true);
            }

            m_PrevSize     = Size;
            m_PrevLocation = Location;

            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize           = (UInt32)Marshal.SizeOf(msgData);
            msgData.hWnd             = Handle;
            msgData.uCallbackMessage = CallbackMessageID;

            // install new appbar
            UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.New, ref msgData);

            IsAppbarMode = (retVal != 0);

            SizeAppBar();

            return(IsAppbarMode);
        }
        private void AppbarGetTaskbarPos(out ShellApi.RECT taskRect)
        {
            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);

            // get taskbar position
            ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetTaskBarPos, ref msgData);
            taskRect = msgData.rc;
        }
        private void AppbarWindowPosChanged()
        {
            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
            msgData.hWnd   = Handle;

            // send windowposchanged to the system
            ShellApi.SHAppBarMessage((UInt32)AppBarMessages.WindowPosChanged, ref msgData);
        }
        private void AppbarSetTaskbarState(AppBarStates state)
        {
            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
            msgData.lParam = (Int32)state;

            // set taskbar state
            ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetState, ref msgData);
        }
        private void AppbarActivate()
        {
            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
            msgData.hWnd   = Handle;

            // send activate to the system
            ShellApi.SHAppBarMessage((UInt32)AppBarMessages.Activate, ref msgData);
        }
        private AppBarStates AppbarGetTaskbarState()
        {
            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);

            // get taskbar state
            UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetState, ref msgData);

            return((AppBarStates)retVal);
        }
        private IntPtr AppbarGetAutoHideBar(AppBarEdges edge)
        {
            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
            msgData.uEdge  = (UInt32)edge;

            // get auto hide
            IntPtr retVal = (IntPtr)ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetAutoHideBar, ref msgData);

            return(retVal);
        }
        private void AppbarSetPos(ref ShellApi.RECT appRect)
        {
            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
            msgData.hWnd   = Handle;
            msgData.uEdge  = (UInt32)m_Edge;
            msgData.rc     = appRect;

            // set postion for the appbar
            ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetPos, ref msgData);
            appRect = msgData.rc;
        }
        private Boolean AppbarSetAutoHideBar(Boolean hideValue)
        {
            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
            msgData.hWnd   = Handle;
            msgData.uEdge  = (UInt32)m_Edge;
            msgData.lParam = (hideValue) ? 1 : 0;

            // set auto hide
            UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetAutoHideBar, ref msgData);

            return((retVal != 0) ? true : false);
        }
        private Boolean AppbarRemove()
        {
            // prepare data structure of message
            ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
            msgData.hWnd   = Handle;

            // remove appbar
            UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.Remove, ref msgData);

            IsAppbarMode = false;

            Size     = m_PrevSize;
            Location = m_PrevLocation;

            return((retVal != 0) ? true : false);
        }
        private void AppbarSetPos(ref ShellApi.RECT appRect)
        {
            // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
              msgData.hWnd = Handle;
              msgData.uEdge = (UInt32)m_Edge;
              msgData.rc = appRect;

              // set postion for the appbar
              ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetPos, ref msgData);
              appRect = msgData.rc;
        }
        private Boolean AppbarSetAutoHideBar(Boolean hideValue)
        {
            // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
              msgData.hWnd = Handle;
              msgData.uEdge = (UInt32)m_Edge;
              msgData.lParam = (hideValue) ? 1 : 0;

              // set auto hide
              UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetAutoHideBar, ref msgData);
              return (retVal != 0) ? true : false;
        }
        private Boolean AppbarRemove()
        {
            // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
              msgData.hWnd = Handle;

              // remove appbar
              UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.Remove, ref msgData);

              IsAppbarMode = false;

              Size = m_PrevSize;
              Location = m_PrevLocation;

              return (retVal != 0) ? true : false;
        }
        private Boolean AppbarNew()
        {
            if (CallbackMessageID == 0)
            throw new Exception("CallbackMessageID is 0");

              if (IsAppbarMode)
            return true;

              m_PrevSize = Size;
              m_PrevLocation = Location;

              // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
              msgData.hWnd = Handle;
              msgData.uCallbackMessage = CallbackMessageID;

              // install new appbar
              UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.New, ref msgData);
              IsAppbarMode = (retVal != 0);

              SizeAppBar();

              return IsAppbarMode;
        }
        private AppBarStates AppbarGetTaskbarState()
        {
            // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);

              // get taskbar state
              UInt32 retVal = ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetState, ref msgData);
              return (AppBarStates)retVal;
        }
        private void AppbarGetTaskbarPos(out ShellApi.RECT taskRect)
        {
            // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);

              // get taskbar position
              ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetTaskBarPos, ref msgData);
              taskRect = msgData.rc;
        }
        private IntPtr AppbarGetAutoHideBar(AppBarEdges edge)
        {
            // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
              msgData.uEdge = (UInt32)edge;

              // get auto hide
              IntPtr retVal = (IntPtr)ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetAutoHideBar, ref msgData);
              return retVal;
        }
        private void AppbarSetTaskbarState(AppBarStates state)
        {
            // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
              msgData.lParam = (Int32)state;

              // set taskbar state
              ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetState, ref msgData);
        }
        private void AppbarWindowPosChanged()
        {
            // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
              msgData.hWnd = Handle;

              // send windowposchanged to the system
              ShellApi.SHAppBarMessage((UInt32)AppBarMessages.WindowPosChanged, ref msgData);
        }
        private void AppbarActivate()
        {
            // prepare data structure of message
              ShellApi.APPBARDATA msgData = new ShellApi.APPBARDATA();
              msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
              msgData.hWnd = Handle;

              // send activate to the system
              ShellApi.SHAppBarMessage((UInt32)AppBarMessages.Activate, ref msgData);
        }