예제 #1
0
        /// <summary>
        /// Looks-up a HTheme handle.
        /// </summary>
        /// <param name="windowClass"></param>
        /// <returns></returns>
        private IntPtr GetHTheme(string windowClass)
        {
            IntPtr hTheme;

            if (!themeHandles.TryGetValue(windowClass, out hTheme))
            {
                if (vistaExplorerThemeOwner == null)
                {
                    vistaExplorerThemeOwner = new Control();
                    vistaExplorerThemeOwner.CreateControl();
                    UXTheme.SetWindowTheme(vistaExplorerThemeOwner.Handle, Explorer, null);
                }

                //special case for TreeView and ListView classes
                //load Vista's Explorer theme if needed
                IntPtr handle       = IntPtr.Zero;
                string classToLower = windowClass.ToLower();
                if (classToLower == VisualStyleElement.TreeView.Item.Normal.ClassName.ToLower() ||
                    classToLower == VisualStyleElement.ListView.Item.Normal.ClassName.ToLower())
                {
                    handle = vistaExplorerThemeOwner.Handle;
                }
                hTheme = UXTheme.OpenThemeData(handle, windowClass);
                this.themeHandles.Add(windowClass, hTheme);
            }

            return(hTheme);
        }
예제 #2
0
        private IntPtr GetHTheme(string windowClass)
        {
            IntPtr num;

            if (!this.themeHandles.TryGetValue(windowClass, out num))
            {
                if (this.vistaExplorerThemeOwner == null)
                {
                    this.vistaExplorerThemeOwner = new Control();
                    this.vistaExplorerThemeOwner.CreateControl();
                    UXTheme.SetWindowTheme(this.vistaExplorerThemeOwner.Handle, "explorer", (string)null);
                }
                IntPtr hwnd  = IntPtr.Zero;
                string lower = windowClass.ToLower();
                if (lower == VisualStyleElement.TreeView.Item.Normal.ClassName.ToLower() || lower == VisualStyleElement.ListView.Item.Normal.ClassName.ToLower())
                {
                    hwnd = this.vistaExplorerThemeOwner.Handle;
                }
                num = UXTheme.OpenThemeData(hwnd, windowClass);
                this.themeHandles.Add(windowClass, num);
            }
            return(num);
        }