15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Changing colours of Property Sheet Tabs ?

Paul Keogh -- paul.keogh@sse.ie
Friday, May 31, 1996


Env: Win 3.1, MSVC 1.52, MFC 2.5

Anyone any ideas on how to change the background colour of a Property Sheet tab ?
I construct a set of pages based on some network data I receive. I would like to 
set the background tab colour of the page(s) which trigger a predefined condition to
indicate to the user that the trigger has occurred.

Regards,
Paul Keogh
SSE





Ed Lenox -- 101721.2225@CompuServe.COM
Friday, June 21, 1996

Paul Keogh wrote->
>Anyone any ideas on how to change the background colour of a Property Sheet tab
?
>I construct a set of pages based on some network data I receive. I would like
to
>set the background tab colour of the page(s) which trigger a predefined
condition to
>indicate to the user that the trigger has occurred.

Have you figured this out yet?
If not, I suggest that you consider using an imagelist and change the image
associated with the tabs,
rather than the background color. 
This is much easier to do than changing the background color of the tabs. 
Also you don't need to worry about colorblind people and stuff like that.

I have included some of the code that we are using to do this at the end of this
message.
C_sheetProperty is a class derived from CPropertySheet, but you can use the base
class just as well.


*There is a slight problem with this method, however. *
(This happens with W95, VC4.1, it might be better with the Win32s common
controls, or it might be worse...)

If you are using the stacked tabs style (m_bStacked, the default),
and if adding the images to the tab control forces an extra row of tabs to be
needed, 
the tab control appears incorrectly (The front row of tabs is half invisible).
I think this is because the size of the tab control/property sheet is not being
recalculated when the images are added.
(The CPropertSheet must be initialized before adding the imagelist, as otherwise
the tab control associated isn't valid)

I get around this problem by switching pages in the OnInitDialog of the sheet. 
The rows then appear properly(with VC4.0, even this didn't work, but it does for
4.1)
The sheet is still one tabrow shorter than it should be, 
but as long as I leave this amount of space free at the bottom of any pages, it
doesn't look wrong.

Of course, if you use the scrolling tab style( Set CPropertySheet::m_bStacked to
FALSE) none of this is not a problem.

If anyone knows a quick fix to this, I'd like to know it.

//Imagelist code for CPropertySheet
// Sets the image list for a tab control
//------------------------------------------------------------------------------
void C_sheetProperty::SetImageList( UINT nBitmapID )
{
    CImageList *pImageList;
    // Build Small Image List
    CTabCtrl *pTabCtrl = GetTabControl();
    VERIFY( NULL == pTabCtrl->GetImageList( ));

    pImageList = new CImageList;
    VERIFY( 0 != pImageList->Create(nBitmapID, 16, 0, RGB( 255, 255, 255 )));
    VERIFY( NULL == pTabCtrl->SetImageList( pImageList ));
    pImageList->Detach();
    delete pImageList;
}

// Sets the image for the control
//------------------------------------------------------------------------------
void C_sheetProperty::SetPageImage( const int iPage, const StatusImageType
enumImage )
{
    CTabCtrl *pTabCtrl = GetTabControl();
    TC_ITEM  theTabCtrlItem;

    ASSERT( NULL != pTabCtrl->GetImageList() );

    theTabCtrlItem.mask = TCIF_IMAGE;
    pTabCtrl->GetItem( iPage, &theTabCtrlItem );
    theTabCtrlItem.iImage = enumImage;
    pTabCtrl->SetItem( iPage, &theTabCtrlItem );
}





| Вернуться в корень Архива |