Solved

WinXP system colors...

Posted on 2004-08-22
8
265 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
 

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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

762 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

20 Experts available now in Live!

Get 1:1 Help Now