Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 1999-08-23
Medium Priority
Last Modified: 2013-12-03
(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.

Question by:samsey
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 14

Expert Comment

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

LVL 22

Accepted Solution

nietod earned 700 total points
ID: 1406174
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.

LVL 22

Expert Comment

ID: 1406175
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...
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

LVL 22

Expert Comment

ID: 1406176
Let me know if you have any questions.

Author Comment

ID: 1406177
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)

LVL 22

Expert Comment

ID: 1406178
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.

Expert Comment

ID: 1406179
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.
LVL 22

Expert Comment

ID: 1406180
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.

Author Comment

ID: 1406181
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.

LVL 22

Expert Comment

ID: 1406182
>> it didn't change the menu and scroll bars
Are they drawn using MFC code that uses GetSysColor?

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (, we saw how to put the Delete button back there where it belongs.  "Delete" is …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

715 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