public static bool CreateInstance(IntPtr windowHandle, out AppWindowInstance instance)
        {
            var menuHandle = User32Methods.GetSystemMenu(windowHandle, false);
            var count      = Imports.GetMenuItemCount(menuHandle);

            if (count > 0)
            {
                instance = new AppWindowInstance(windowHandle);
                return(true);
            }

            instance = null;

            return(false);
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing && this.Disposed == false)
            {
                this.Disposed = true;

                foreach (var item in this.Items)
                {
                    item.Dispose();
                }

                this.Items.Clear();

                User32Methods.GetSystemMenu(this.Window.Handle, true);
            }
        }
 public AppWindowInstance(IntPtr windowHandle)
 {
     this.Window     = WindowFactory.CreateWindowFromHandle(windowHandle);
     this.MenuHandle = User32Methods.GetSystemMenu(this.Window.Handle, false);
 }