?
Solved

WinXP system colors...

Posted on 2004-08-22
8
Medium Priority
?
272 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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 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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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