Solved

How to make a tab item grey?

Posted on 2002-04-25
9
232 Views
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?
0
Comment
Question by:MakeItWork614
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 4

Expert Comment

by:mblat
Comment Utility
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 - www.codeguru.com ) 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 http://codeguru.com/propertysheet/tab_image.shtml
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....
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
0
 

Author Comment

by:MakeItWork614
Comment Utility
>>If you want to explore this option, let me know.

Yes, I'm interested.
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
Comment Utility
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++ ) {
          RemovePage(0);
     }
     // then add back the relevant ones...
     if (...whatever...) AddPage( m_pg1 );
     if (...whatever...) AddPage( m_pg2 );

...etc...

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
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Have you been helped here, or is more needed?
Moondancer - EE Moderator
0
 

Author Comment

by:MakeItWork614
Comment Utility
DanRollins,
I'll test this out, and award you the points if it works.

Thanks
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
Thank you for your responsiveness.  Moondancer - EE Moderator
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
hi MakeItWork614,
Do you have any additional questions?  Do any comments need clarification?

-- Dan
0
 
LVL 1

Expert Comment

by:Moondancer
Comment Utility
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
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now