Highlight the Active Page of a TabControl

Environment: VC6 SP4

Overview

In an application that sports TabControls with several rows of tabs, it can often be difficult for the user to distinguish which tab has focus. Therefore, this code will enable you to easily hilight the text of the active tab (see image above).

Usage

There are only two property page functions to implement (OnSetActive and OnKillActive)
BOOL CMyPage::OnSetActive() 
{
 CPropertySheet* pParent = (CPropertySheet*)this->GetParent();

 if (pParent)
 {
  if (pParent->GetTabControl())
  {
   short nActiveItem = pParent->GetPageIndex(this);
   pParent->GetTabControl()->HighlightItem(nActiveItem);
  }
 }   
 
 return CPropertyPage::OnSetActive();
}
BOOL CMyPage::OnKillActive() 
{
 CPropertySheet* pParent = (CPropertySheet*)this->GetParent();
 if (pParent)
 {
  if (pParent->GetTabControl())
  {
   short nActiveItem = pParent->GetPageIndex(this);
   pParent->GetTabControl()->HighlightItem(nActiveItem, FALSE);
  }
 }   

 return CPropertyPage::OnKillActive();
}

Downloads

Download demo project - 42 Kb


Comments

  • How do i change the title of the property page?

    Posted by Legacy on 02/06/2003 12:00am

    Originally posted by: Simon Soosai

    I have 3 property pages. Title on the property page 3 is based on the selection of page 2. So how do i change the title of the property page 3?

    Reply
  • Change Highlight Colour?

    Posted by Legacy on 05/31/2002 12:00am

    Originally posted by: Ramesh

    How do i change the highlight color?

    Reply
  • Thx

    Posted by Legacy on 12/07/2001 12:00am

    Originally posted by: coldrg

    Thanks author!

    coldrg
    ===========================================
    http://www.vistoolbox.com
    Boost windows with extra useful functions!
    ===========================================

    Reply
  • How do I read/write to the custom file properties

    Posted by Legacy on 09/10/2001 12:00am

    Originally posted by: Jeremey Dobrzanski

    I need to read and write to the standard custom file properties page that MS Doc and 3dsmax files have.
    If you pull up the properties on a word doc file and go to the custom tab, you'll know what I am talking about. This seems to be a standard tab that applications can had to their files but I can find documentation on it anywere. Is there some API for creating these tabs and reading/writing to the properties? Thanks

    Reply
  • hmm... he gives a warning

    Posted by Legacy on 08/07/2001 12:00am

    Originally posted by: Sebastian

    I've installed SP5 and he gives me a warning.
    
    I've changed a line into:
    short nActiveItem = (short)(pParent->GetPageIndex(this));
    (In KillActive and SetActive of course...)

    Reply
  • Got it!

    Posted by Legacy on 06/12/2001 12:00am

    Originally posted by: Umut

    Thanks for your work. I found what I been looking for.

    Reply
  • It works perfectly, but...

    Posted by Legacy on 06/10/2001 12:00am

    Originally posted by: Sebastian

    ...can anyone tell me how i can change the highlight color into different colors?

    Reply
  • Question

    Posted by Legacy on 05/28/2001 12:00am

    Originally posted by: mrv

    Great work.
    How do i control the position of the PAGES in the Sheet??
    Say i want to to start them from 100,100 from the parent.??
    Any idea. Need this in Wizard style.
    Help me.

    Thanks
    mrv

    Reply
  • Great

    Posted by Legacy on 05/25/2001 12:00am

    Originally posted by: Peter O'Connor

    You are to be highly commended for such fantastic work.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • A help desk is critical to the operations of an IT services business. As a centralized intake location for technical issues, it allows for a responsive and timely solution to get clients and their staff back to business as usual. In addition to handling immediate IT issues, a help desk performs several proactive tasks to ensure clients' IT systems remain operational and downtime is minimized. Thus, utilizing a help desk and following best practices can improve the productivity, efficiency and satisfaction of …

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds