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

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


Coloring tabs in a CTabCtrl...

spillman!bworthen@uunet.uu.net
Tuesday, April 01, 1997

Environment: VC++ 5.0, Win 95, NT 4.0

I have a dialog based application that has a CTabCtrl in the
dialog. I would like to allow the user to have control over
the number of tabs in the tab control (within a reasonable
limit) as well as the color of each tab.  For example, if
the user has chosen a tan color for the first tab, then the
whole tab (display area plus the tab along the top) would be
a tan color.  The tab's text, and possibly an icon for the
tab, would be displayed "on top" of the color.  If a
different tab was selected (for example, the third tab), the
user would still be able to see the first tab, with its tan
color, behind the currently selected tab.  In other words,
even though a tab isn't the currently selected one, the tab
portion that is visible to the user would still have the
coloring that the user specified. My question is:  Is this
possible and what is the best way to go about pulling this
off?  I've tried some things, such as trying to color the
background and tab when an erase background message is sent,
but I can't get this to work for me.  I've also searched
MSDN, etc., at length and can't find anything that pertains
to this. Does anybody have some suggestions?

Brad
uunet!bworthen!spillman.com



Ben Burnett -- benner@supernet.ab.ca
Wednesday, April 02, 1997

spillman!bworthen@uunet.uu.net wrote:
>=20
> Environment: VC++ 5.0, Win 95, NT 4.0
>=20
> I have a dialog based application that has a CTabCtrl in the
> dialog. I would like to allow the user to have control over
> the number of tabs in the tab control (within a reasonable
> limit) as well as the color of each tab.  For example, if
> the user has chosen a tan color for the first tab, then the
> whole tab (display area plus the tab along the top) would be
> a tan color.  The tab's text, and possibly an icon for the
> tab, would be displayed "on top" of the color.  If a
> different tab was selected (for example, the third tab), the
> user would still be able to see the first tab, with its tan
> color, behind the currently selected tab.  In other words,
> even though a tab isn't the currently selected one, the tab
> portion that is visible to the user would still have the
> coloring that the user specified. My question is:  Is this
> possible and what is the best way to go about pulling this
> off?  I've tried some things, such as trying to color the
> background and tab when an erase background message is sent,
> but I can't get this to work for me.  I've also searched
> MSDN, etc., at length and can't find anything that pertains
> to this. Does anybody have some suggestions?
>=20
> Brad
> uunet!bworthen!spillman.com

It is possible to do what you are proposing but you will find that
it takes allot of work, I personally haven=92t tried doing this but it
should work if you derive a class from CPropertyPage ( ofcouse ) and
handle the back ground color stuff, then to get the tabs to be different
colors you have to derive a class from the tab ctrl, Not the actual
CPropetySheet but the undocumented tab ctrl within it. I cant at the
moment recollect the name of the class but its in the mfc source file in
the same file as the CPropetySheet source. As for the implementation of
all of this, that would probably be left to your creative mind.

Hope this helps.


--=20
----------------------------------------------
 Reality is for those who have no imagination=20

 Ben Burnett   /   Pulse productions
 e-mail: benner@supernet.ab.ca



R.H.J. Geraets -- R.Geraets@Ehv.Tass.Philips.Com
Wednesday, April 02, 1997

[Mini-digest: 2 responses]

At 01:34 PM 4/1/97 +0000, you wrote:
>Environment: VC++ 5.0, Win 95, NT 4.0
>
>I have a dialog based application that has a CTabCtrl in the
>dialog. I would like to allow the user to have control over
>the number of tabs in the tab control (within a reasonable
>limit) as well as the color of each tab.  For example, if
>the user has chosen a tan color for the first tab, then the
>whole tab (display area plus the tab along the top) would be
>a tan color.  The tab's text, and possibly an icon for the
>tab, would be displayed "on top" of the color.  If a
>different tab was selected (for example, the third tab), the
>user would still be able to see the first tab, with its tan
>color, behind the currently selected tab.  In other words,
>even though a tab isn't the currently selected one, the tab
>portion that is visible to the user would still have the
>coloring that the user specified. My question is:  Is this
>possible and what is the best way to go about pulling this
>off?  I've tried some things, such as trying to color the
>background and tab when an erase background message is sent,
>but I can't get this to work for me.  I've also searched
>MSDN, etc., at length and can't find anything that pertains
>to this. Does anybody have some suggestions?
>
>Brad
>uunet!bworthen!spillman.com
>

You can make the tab control owner-draw, and color the tab"buttons"
in the drawitem handler (this allows you to give each "button" a
different color. You can give a color to the "pages" of the
tab control by handling WM_CTLCOLOR messages for the tab control.

Let me know if you need more info.

  Rene' Geraets
  R.Geraets@ehv.tass.philips.com



-----From: "George T. Pavlou" 

If you want the tabs colored then you should go with ownerdraw tabctrl. You
override the DrawItem() and so on, same procedure as any other ownerdraw
contrlol.

For the display area you override the OnEraseBkgnd() and depending which
one is selected you fill the display area with your color.

George

 |-------------------------------------------------------------------------|

   George T. Pavlou                       Tantalus, Inc.            
   PC Software Specialist            Key West, FL
   georgep@tansoft.com             www.mpgn.com 
|-------------------------------------------------------------------------|

----------
> From: spillman!bworthen@uunet.uu.net
> To: uunet!netcom.com!mfc-l@uunet.uu.net
> Subject: Coloring tabs in a CTabCtrl...
> Date: Tuesday, April 01, 1997 8:34 AM
> 
> Environment: VC++ 5.0, Win 95, NT 4.0
> 
> I have a dialog based application that has a CTabCtrl in the
> dialog. I would like to allow the user to have control over
> the number of tabs in the tab control (within a reasonable
> limit) as well as the color of each tab.  For example, if
> the user has chosen a tan color for the first tab, then the
> whole tab (display area plus the tab along the top) would be
> a tan color.  The tab's text, and possibly an icon for the
> tab, would be displayed "on top" of the color.  If a
> different tab was selected (for example, the third tab), the
> user would still be able to see the first tab, with its tan
> color, behind the currently selected tab.  In other words,
> even though a tab isn't the currently selected one, the tab
> portion that is visible to the user would still have the
> coloring that the user specified. My question is:  Is this
> possible and what is the best way to go about pulling this
> off?  I've tried some things, such as trying to color the
> background and tab when an erase background message is sent,
> but I can't get this to work for me.  I've also searched
> MSDN, etc., at length and can't find anything that pertains
> to this. Does anybody have some suggestions?
> 
> Brad
> uunet!bworthen!spillman.com




Become an MFC-L member | Вернуться в корень Архива |