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

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


Changing the Color of Toolbars

Bill E. Kempf -- WEKempf@marlton.1dc.com
Tuesday, April 02, 1996


Ok, sorry it's taken so long for me to reply to this, but we are busy with 
other things, and the coloring has a low priority (though we do need to 
resolve this).  Your suggestion, as well as simply taking over any of the 
drawing messages to paint ourselves, does not fix what we have problems 
with.  To clarify, your method does change the background color of the 
toolbar, but not of the non-client area.  When a toolbar is docked, the 
actual toolbar takes up only the amount of space required for the 
number/size of buttons, but the entire horizontal/vertical area of the 
entire window then becomes non-client area and is colored in GREY.  We want 
to change this color to use our own custom background color.

Changing the background for the toolbar does not help.  Changing the color 
for the frame does not help.  What are we left with?  How do we change this 
color?

 ----------
From: owner-mfc-l
To: mfc-l
Subject: Re: Changing the Color of Toolbars
Date: Wednesday, March 20, 1996 2:03PM


Text item:


Derive your own CToolBarCtrl or CToolBar based class and overide
PreCreatewindow().  In your PreCreateWindow(), register the class yourself 
by
calling AfxRegisterWndClass() with the HBRUSH parameter set to the brush you 

want to use.  Another way to do it would be to overide OnPaint and then
select
the brush into the DC and blt it every time, but I think the first method is 

nicer.


______________________________ Reply Separator
_________________________________
Subject: Changing the Color of Toolbars
Author:  owner-mfc-l@netcom.com at SMTPGATE
Date:    3/15/96 4:00 PM


Environment: VC++ 4.0 / Win NT patch 3

Is there any way to dynamically change the color used in the background
portion of a CToolBarCtrl?  We do not want to change the global colors that
these are based off of, as this will cause buttons to display improperly.
 We just want to change them to use our applications background.  Is there a
message that can be overriden to provide our own color?  Has anyone else
found a way to do this?

Thanks for any help.

William E. Kempf
wekempf@marlton.1dc.com

 --
Deepak Saxena                          | "We live,        | These opinions 
are
Deepak_Saxena@ccm.ch.intel.com         |  as we dream-    | mine and do not 
in
http://cernan.ecn.purdue.edu/~deepak   |  alone"          | any way 
represent
Home:(602)812-8933, Work:(602)554-1304 |   Joseph Conrad" | Intel 
Corporation.


Text item: External Message Header

The following mail header is for administrative use
and may be ignored unless there are problems.

***IF THERE ARE PROBLEMS SAVE THESE HEADERS***.

Reply-To: mfc-l@netcom.com
Precedence: list
Sender: owner-mfc-l@netcom.com
X-Mailer: Microsoft Mail V3.0
Encoding: 14 TEXT
Message-ID: <314A21CB@msmail.marlton.1dc.com>
Date: Fri, 15 Mar 96 16:00:00 PST
Subject: Changing the Color of Toolbars
To: MFC-L 
From: "Bill E. Kempf" 
Received: by netcom11.netcom.com (8.6.13/Netcom)
     id SAA02352; Sat, 16 Mar 1996 18:26:28 -0800
Received: from netcom11.netcom.com (root@netcom11.netcom.com
[192.100.81.121]) b
y ormail.intel.com (8.7.4/8.7.3) with SMTP id AAA03568 for
; Sun, 17 Mar 1996 00:16:16 -0800 (PST)
Received: from ormail.intel.com (ormail.intel.com [134.134.192.3]) by
relay.jf.i
ntel.com (8.6.12/8.6.12) with ESMTP id AAA12159 for
; Sun, 17 Mar 1996 00:16:18 -0800
Return-Path: owner-mfc-l@netcom.com



Mike Blaszczak -- mikeblas@msn.com
Thursday, April 04, 1996

----------
From: 	owner-mfc-l@netcom.com on behalf of Bill E. Kempf
Sent: 	Tuesday, April 02, 1996 12:48 PM

> Ok, sorry it's taken so long for me to reply to this, but we are busy with 
> other things, and the coloring has a low priority (though we do need to 
> resolve this).  Your suggestion,

The suggestions I saw were very accurate.  It's the question that was 
inspecific, I think.

> as well as simply taking over any of the 
> drawing messages to paint ourselves, does not fix what we have problems 
> with. 

Why didn't your question reflect what you were having problems with?

> To clarify, your method does change the background color of the 
> toolbar, but not of the non-client area.  When a toolbar is docked, the 
> actual toolbar takes up only the amount of space required for the 
> number/size of buttons, but the entire horizontal/vertical area of the 
> entire window then becomes non-client area and is colored in GREY. 

PLEASE USE SPY++. 

If you use Spy++, you can see exactly what's going on: that area behind the 
toolbar doesn't have anything to do with the toolbar.  Instead, it's actually 
a separate window, entirely.  If you want to change the colour of that window, 
you'll need to change the way that window paints itself.

Most questions on this list dealing with windows and painting could be 
answered with Spy++.  Someone at Microsoft worked very hard to write this 
tool.  It breaks my heart that someone worked so hard to write this cool tool, 
a couple of people agreed that it belonged on the Tools menu and got it there, 
and then nobody uses it.  Instead, they shut down Visual C++, and start up 
their EMAIL program.  That's more work, isn't it?

> We want 
> to change this color to use our own custom background color.

Handle the WM_ERASEBKGND message for the window I've told you about.  I'm not 
going to tell you the class that handles all this or tell you what else to do 
because you need to learn to use Spy++.

> Changing the background for the toolbar does not help.  Changing the color 
> for the frame does not help.  What are we left with?  How do we change this 
> color?

Certainly, changing the background color for the toolbar _does_ help. You need 
to change both the background color for your toolbar and the background color 
for the docking window so they match.  The frame is completely uninvolved 
here--and you'd know that if you used Spy++.

Boy, I just realized: you typed that whole big note and did not even find room 
for a "Thank you", huh?  Since it was a follow up question, you could have 
even avoided the insincere little "Thanks in advance" thing that seems to be 
so popular these days.

.B ekiM






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