• 0

[C#] Tabcontroller with new Windows 7 functionality


Question

Hi,

I'm trying to utilize the new Windows 7 API code pack to create a TabController in my app that displays tabs as thumbnails in the Win7 taskbar. However, I have been unable to make it function properly. There are probably some small errors in the code that I have attached below, but at the moment I am unable to see what I have done wrong. My code is based on the 'TabbedThumbnailDemo' from the Win7 API Code pack. Can anybody see what I have done wrong from the following exerpt?:

        /// <summary>
        /// Create a new tab in controller with the 'home' page (UserControl)
        /// </summary>
        private void AddHomeTab()
        {
            TabPage home = new TabPage("Home");
            home.ImageIndex = 0;
            home.Controls.Clear();

            home.Controls.Add(new Home());
            tabControl.TabPages.Add(home);

            AddThumbnail(home);

        }


        /// <summary>
        /// Create a thumbnail for a TabPage
        /// </summary>
        /// <param name="page">The tab to create thumbnail from</param>
        private void AddThumbnail(TabPage page)
        {
            if (TaskbarManager.IsPlatformSupported)
            {
                TabbedThumbnail preview = new TabbedThumbnail(this.Handle, page.Handle);

                preview.TabbedThumbnailActivated += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailActivated);
                preview.TabbedThumbnailClosed += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailClosed);
                preview.TabbedThumbnailMaximized += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailMaximized);
                preview.TabbedThumbnailMinimized += new EventHandler<TabbedThumbnailEventArgs>(preview_TabbedThumbnailMinimized);

                preview.Title = page.Name;

                TaskbarManager.Instance.TabbedThumbnail.AddThumbnailPreview(preview);

                tabControl.SelectedTab = page;
                TaskbarManager.Instance.TabbedThumbnail.SetActiveTab(tabControl.SelectedTab);

                if (tabControl.TabPages.Count > 0 && tabControl.SelectedTab != null)
                    UpdatePreviewBitmap(tabControl.SelectedTab);
            }
        }


        private void UpdatePreviewBitmap(TabPage tabPage)
        {
            if (tabPage != null)
            {
                TabbedThumbnail preview = TaskbarManager.Instance.TabbedThumbnail.GetThumbnailPreview(tabPage);


                if (preview != null)
                {
                    Bitmap bitmap = TabbedThumbnailScreenCapture.GrabWindowBitmap(tabPage.Handle, tabPage.Size);

                    bitmap.Save("img.png");
                    preview.SetImage(bitmap);
                }


            }
        }

I call AddHomeTab() in the end of my constructor. While debugging it seems that everything is OK (TaskbarManager.Instance.TabbedThumbnail will list all my tabs for instance), but the taskbar does not update with new thumbnails at all.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

If you want to PM me a link to the actual source code + project files (or at least enough of the code to allow that code snippet to run) I'll try seeing if I can find the problem for you. Too much work for me to create a new project and implement your code just to try and solve the problem. I have worked with the Win7 APIs though (made an app launcher using jump lists and interactive thumbnails, though its not using a separate thumbnail per tab).

Otherwise, maybe someone else here can help.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.