Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - MDI tab colors on per tab basis
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

MDI tab colors on per tab basis

 Post Reply Post Reply
Author
Message
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 891
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Topic: MDI tab colors on per tab basis
    Posted: 17 November 2016 at 5:50pm
I would like to user differing background colors for tabs. So far it looks like it is an all or nothing scenario. What I would like to do is let the user open a document and then color the background of the tab item for the document with a special color if the document is read-only. So for instance we currently have a dark blue tab color for the selected tab and white for unselected tabs. But if the user selects a document that is read-only, I want to change the color of the selected tab.

Ideally this would be a color I could set in the tab item but I didn't see that. I do implement WM_XTP_PRETRANSLATEMOUSEMSG so I can trap mouse clicks. So I could trap the user activating a tab via the mouse. I also have code that draws the navigation button and it calls GetColorSet.

I could live with only coloring the active tab differently when the file is read-only. Hence I could detect when the MDI tab is activated and then change a color. I found CXTPTabClientWnd::OnMDIActivate/MDIActivate methods. I already subclass CXTPTabClientWnd so I can implement a handler for the former or override the latter since when I click a tab item, they are called. But not when I control-tab, control-shift-tab. However I can probably work that out as I have MDI message handling in my frame.

So I think the only thing I haven't figured out yet is how to get the color being used to draw the selected item so I can change it when the newly selected item for a read-only document.

Does anyone know how I can access that color and change it?
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 891
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 17 November 2016 at 6:10pm
Ok. So I found the color set and GetItemColor uses m_clrButtonSelected. I can change that value's custom color, which is being used in my case, to a different value and I see the selected tab (and the lower border of the tab client) drawn with that color. So now I just need to figure out how to change m_clrButtonSelected. GetItemColor is virtual but it looks like I have to handle each tab color set that can be created as the user changes command bar themes.

I see no method that lets me set m_clrButtonSelected. It is public so I could just directly change the color but that's not robust (what if it goes private).

Any suggestions on an alternative way to do this would be appreciated. Especially if it is something simple that I am missing.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.188 seconds.