• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 223
  • Last Modified:

How to not use system colours in VC++[6]?

(Visual C++ v6, MFC app)
I am writing an app which needs a very distinctive look.
Basically I want to have full control over the colour of the entire application window:
Scroll bars, toolbar, status bar etc.
I want to change the shades of grey to blue, so it would be like changing the windows system colours for just this app.
I'd also like to change the colours of items like the splitters in toolbars, etc.

I'm not sure how I should go about doing this. I really need away that is quick to implement.

Can I override GetSysColor to return the colours I want (how)?
Do I have to override each control (using mfc classes)?

If someone could tell me the best way to do this (if there is one), I would be very grateful.

1 Solution
Can be simplest way use function SetSysColors
(see Windows Doc). But with this way you change colors
to ALL apps , running in this time!

You can change the window's background by overiding the OnEraseBkGnd() procedure or by changing the window's background brush handle.

You can change the appearance of child windows (controls) by handling the "color" messages sent by the control to the parent in the OnCtlColor() message handler.

This allows you to change the appearance of the client area of your windows, i.e. you can change the color of the client area of a parent window and change the appearance of all the controls that appear in that client area.  Changing the appearance of the non-client area of a window (like the title bar) is harder, but I don't know if you need that...
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Let me know if you have any questions.
samseyAuthor Commented:
Thanks but...

I didn't have a problem with changing the colour of the client area, but what I wanted to know about was changing the colour of the scroll bar, and toolbar, menu etc.
As if I were to change the system colours but only for my app.
I believe GetSysColor provides the colors for the controls including shading etc. I thought that maybe if I replace this with my own function I could return my own colors.
I don't know if this is a feasible.
I don't want to use the normal colors in any part of the app.
I'm aware this could be quite difficult, I don't really want to have to over ride each button and control.

(It's an SDI app)

Did you try onCtlColor?  It will let you change the color of child controls.  This will definitely work for controls that appear in the client area, scroll controls, buttons, sliders etc...   I don't know if it will work for the non-client controls, like menus, but I suspect it might.  Try it and let me know.
Good luck. Bill G. didn't cover all the bases in this area. For example, if you override a scroll bar's color using onCtlColor, only the scroll bar face color will change. The 3-d elements of the scroll bar will remain system color. It will look pretty aweful. This applies to other 3-d controls as well. The only method I can think of is to manually draw the controls which is certainly ALOT of work.
It depends on the controls, some do better than others.  They all allow you to change the background, which is the most important feature, otherwise the areas of the control's rectangle that aren't supposed to look like the control would appear the wrong color. I've seen programs that do use the color messages to do this and the results can be pretty good.  Writing your own controls is much harder--I know--I wrote all of mine.
samseyAuthor Commented:
I have been having ago at changing the colors over the last day or so.
I have been trying to do this by replacing calls to GetSysColor in the mfc library (by compiling the code in the mfc\src directory) and replacing them with a call to my function GetSysColorEx which returns the colour I want for the items I want to change the color of and calls GetSysColor to return the system color for the items which can remain as system colors.(I use mfc statically linked).

It worked for the classes that I overwritten in my application like the views and toolbars etc.
So the window border, background and toolbar changed color.
but it didn't change the menu and scroll bars.
I think this method seems to be working, but I need to improve it so that it includes the other controls.

I'd like to know what people think of this method, and whether they have any suggestions.

>> it didn't change the menu and scroll bars
Are they drawn using MFC code that uses GetSysColor?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now