Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

WinXP system colors...

Posted on 2004-08-22
8
Medium Priority
?
273 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
[X]
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
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 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 500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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