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
Solved

WinXP system colors...

Posted on 2004-08-22
8
269 Views
Last Modified: 2010-04-05
Hello!

Is there a way to calulate the gradient colors used in XP-toolbars and menus? I'm trying to
develop a panel the should have a gradient fill like these toolbars. (from "yellowish" start to "silver)

Hokki
 
0
Comment
Question by:hakanfa
8 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 11864507
0
 

Author Comment

by:hakanfa
ID: 11864605
Hmm.. I wasn't specific enough. This gradient fill i OK but what I'm looking for i a way to determine what colors windows uses. Lets take MS Office as example. If You use the "color scheme" blue the menus are blue, if you use green they are green and so on..Then the menus starts with a lighter color and ends with a much darker one, but still in line with the windows color scheme. I think..they use som kind of "base" color from the scheme and "lightens" it and "darkens" it with a standard set of parameters..don't know but it sound logical? So to put the question more straight, I would like to know how to determine the "base color" (blue, green, silver..) and then how to get the "start" color and the "end" color, and of course the "gradientfill" effect!. I increase the points to 250 for a good snap of code..

Hokki
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11866516
you can use GetSysColor API function to get the colors you need:

the first color you need is
COLOR_ACTIVECAPTION - Active window caption

var
  Color1 : DWORD;
begin
  Color1 := GetSysColor(COLOR_ACTIVECAPTION);

the second color is ... I don't know which color exactly you need, because it is late and I can not focus on them, but it should be there.

After that it is easy to make gradient between these 2 colors.
0
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.

 

Author Comment

by:hakanfa
ID: 11878749
Hmm, well yes. But I wonder if there is a way to "calculate" the gradient effect? Like the
begin color - end color? As I said, I saw somewhere (a discussion forum) that this can be
done with use of as "basecolor" from wich you (with some kind of algorithm) calculates the
gradient colors.. Maybe I'm out flying high on this one :) ?

Hokki

0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11878818
0
 
LVL 34

Expert Comment

by:Slick812
ID: 11884550
hell hakanfa, ???
 I know that in systems before win XP (and even in XP if themes is turned off), I think for the Title Bar's colors (begin gradient and end gradient) you can set these colors to any color you want, in the DeskTop properties dialog?, so I am not sure what kind of "algorithm" you want to have here, In office there may be a base color, but I would not know how to get the formular for lighter and darker used in there, I do not think it is a system API function. . .
If you just want to darken and lighten a Color, from a base color you might try this button Click -



procedure TForm1.sbut_GradColorsClick(Sender: TObject);
var
BaseColor, LiteColor, DarkColor: TColor;
bR, bG, bB, offSet: Byte;

  function LimitByte(by1: Integer): Byte;
  begin
  if by1 > MaxByte then
    Result := MaxByte
    else
    if by1 < 0 then
    Result := 0
    else
    Result := by1;
  end;

begin
BaseColor := $CC99CC; // color to make lighter and darker
offSet := $3A; // amount to lighten and darken, increase for greater difference

bR := GetRValue(BaseColor);
bG := GetGValue(BaseColor);
bB := GetBValue(BaseColor);

// add to base to lighten
LiteColor := RGB(LimitByte(bR+OffSet), LimitByte(bG+OffSet), LimitByte(bB+OffSet));
// subtract from base to darken
DarkColor := RGB(LimitByte(bR-OffSet), LimitByte(bG-OffSet), LimitByte(bB-OffSet));

PaintBox1.Canvas.Brush.Color := BaseColor;
PaintBox1.Canvas.Rectangle(1,1, 41, 31);
PaintBox1.Canvas.Brush.Color := LiteColor;
PaintBox1.Canvas.Rectangle(1,41, 41, 71);
PaintBox1.Canvas.Brush.Color := DarkColor;
PaintBox1.Canvas.Rectangle(1,81, 41, 111);
end;
0
 

Accepted Solution

by:
krio earned 125 total points
ID: 11902554
You can get both color with the GetSysColor function:

COLOR_ACTIVECAPTION specifies the left side color
COLOR_GRADIENTACTIVECAPTION is the right side color (not supported for Win NT or Win95)

you can also get the values for an inactive caption:
COLOR_INACTIVECAPTION for the left side, and
COLOR_GRADIENTINACTIVECAPTION for the right side (not supported for Win NT or Win95)

You can also use the SystemParametersInfo function to determine whether the gradient effect for window title bars is enabled:
Example:
function GradientEnabled: boolean;
var
  b: Cardinal;
begin
  Windows.SystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, @b, 0);
  Result:=b<>0;
end;
0
 

Author Comment

by:hakanfa
ID: 12041615
Thanks for your help. Works fine!
Back in business again.. ;)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

837 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