How to make a tab item grey?

Posted on 2002-04-25
Last Modified: 2013-11-20
I want to disable a tab item, and make it grey, so the user know that it's not selectable.

How do I grey out a single tab?
Question by:MakeItWork614
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1

Expert Comment

ID: 6969080
Bad news is that there is no function call to disable one tab control item out of several.

Good news is that there is several ways to accomplish what you want.

1. You can create owner draw tab control.  That is not difficult.  Find a sample on net that deals with owner draw button ( one place to look - ) and go from there.

2. Second way is to place icon that will mean that this item is disabled, and intercept selection messages Then you can refuse selection on "disabled" items ( that would be items with or without marker).  That not exactly what you want, but if you don't want to deal with owner draw control it'll do.  Look on
for example.

3. I know this is exactly what you DON'T WANT, but.... You can remove item completely?  Or is that not an option at all?

Hope it helps....
LVL 49

Expert Comment

ID: 6970026
When I don't want my user to click a tab, I remove the CPropertyPage from the CPropertySheet.  That is the standard U/I as far as I can tell.  Sometimes you end up with a one page sheet, but users have seen this bahavior all throughout Windows, so there is no surprise.

If you want to explore this option, let me know.

-- Dan

Author Comment

ID: 6970181
>>If you want to explore this option, let me know.

Yes, I'm interested.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 49

Accepted Solution

DanRollins earned 100 total points
ID: 6970530
What I do:
I derive CMySheet from CPropertySheet and I add a member function:

CMySheet::SetPages( ...whatever... )
     //-- first, remove all pages
     int nCnt= GetPageCount();
     for (int j=0; j<nCnt; j++ ) {
     // then add back the relevant ones...
     if (...whatever...) AddPage( m_pg1 );
     if (...whatever...) AddPage( m_pg2 );


I call this with a 'normal' or default setting right befor the call to CMySheet.DoModal().

There is one tricky part:
Typically there will be one of the pages that causes other pages to be added or removed.  When that happens, you can't just call the SetPages fn because things are about to get shaken up considerably.  So in CMySheet, I add:

     ON_MESSAGE( UM_SetPgsForProd, OnSetPgsForProd ) // safe way to shuffle pages

to the message map.  And I add a fn:

LRESULT CDlgSheetInq::OnSetPgsForProd( WPARAM eProd, LPARAM )
     SetPgsForProd( (Prod)eProd, FALSE /*fInitial*/ );
     return( 0 );

Then when I need to add/remove (say in an OnClick in DlgPage_3), I use:

     CMySheetInq* pcSheet= (MySheetInq*)GetParent();
     // this ends up doing InitDialog
     pcSheet->PostMessage( UM_SetPgsForProd, m_eProd, 0 );

-- Dan

Expert Comment

ID: 6973501
Have you been helped here, or is more needed?
Moondancer - EE Moderator

Author Comment

ID: 6976881
I'll test this out, and award you the points if it works.


Expert Comment

ID: 6977769
Thank you for your responsiveness.  Moondancer - EE Moderator
LVL 49

Expert Comment

ID: 7007788
hi MakeItWork614,
Do you have any additional questions?  Do any comments need clarification?

-- Dan

Expert Comment

ID: 7011069
As Dan said on April 25, 2002 and again on 5/13/2002, if clarification is needed, please advise.

This was finalized today.

Moondancer - EE Moderator

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question