Solved

WinXP system colors...

Posted on 2004-08-22
8
267 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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 33

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

815 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now