?
Solved

clButtonX colors in CoolBar.Bitmap

Posted on 1998-08-16
11
Medium Priority
?
296 Views
Last Modified: 2008-02-01
How can I put a clButtonFace, clButtonHighlight and clButtonShadow based bitmap in the Bitmap property of a CoolBar (clButtonFace<>clSilver!!!) -- like in the Microsoft Internet Explorer 3.x?
0
Comment
Question by:biroadam
[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
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1336138
Have an ImageList component that contains the three images, and when needed use the appropriate one..

Regards,
Viktor Ivanov
0
 

Author Comment

by:biroadam
ID: 1336139
1. There is ONE BITMAP which contains clButtonFace, clButtonHighlight and clButtonShadow colors (beside other colors).
2. The ListView component doesn’t have a Bitmap property, so I can’t put a bitmap from an ImageList into a CoolBar.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1336140
I'm not sure what you're talking about! Please provide an example source...

>2. The ListView component doesn’t have a Bitmap property, so I can’t put a
>     bitmap from an ImageList into a CoolBar.

What do you mean by this???

//Viktor Ivanov
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:biroadam
ID: 1336141
 I want my CoolBar’s bitmap just like the Internet Explorer’s, so the bitmap must contain the clButtonHighlight color. Becouse the clButtonHighlight isn’t a certain color, I have to make a bitmap using clSilver, for example, instead of clButtonHighlight, and I have to substitute it.
  It’s true that the ListView component has a few properties for color control, but
  1. I’m not sure that it’s enough to resolve my problem
  2. I don’t know how can I get a bitmap from a ListView component?
  CoolBar1.Bitmap:=ListView1.???
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1336142
Just one question....

Why do you need a bitmap for that thing to happen....Can't you use the ColorDialog component just to see what's the hex values for the colors you need, and then assign those values to the colors....

For example it would be something like this....

const
   clButtonFace = $000040
   clButtonHighlight =  $00F040
   clButtonShadow =   $0F0040
{I'm not sure if there are colors like this but just to show you what it is suppose to look like}
procedure Whatever........
begin
   Form1.Color := clButtonFace;//You can also assign the other colors...
end;

If that's not what you want or don't understand how to do it just tell me what each of the colors suppose to look like....Ex. clButtonFace = Similar to clSilver...or something like that

Regards,
Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1336143
Another example, but this time a real color value ....

const
  OneOfManyOranges = $000080FF;//This is orange color
procedure whatever.....
begin
  Form1.Color := OneOfManyOranges;//Now the color of the form will become orange
end;

Is that what you were looking for...???

Regards,
Viktor Ivanov
0
 

Author Comment

by:biroadam
ID: 1336144
Dear Viktor Ivanov,

Thank you for your time, bu I still got no answer for my problem.
I will try to explain it again.
There is no reason to do something like this:
const
   clButtonFace = $000040
   clButtonHighlight =  $00F040
   clButtonShadow =   $0F0040,
becouse clButtonFace is the current color of the buttons’ face, and it’s provided by Windows (and can be changed in Display Properties / Appearance box; for example, choosing the "Desert" scheme). So my program’s purpose is to display a bitmap (as the background bitmap of a CoolBar component) using the current button colors (it’s very ugly a gray-colored bitmap on sand-colored window, beside of sand-colored buttons).
  If I do not hide the Windows-provided clButtonFace system variable (as you proposed), my program will know the current button color on any computer, and I think it’s possible to substitute some colors in a bitmap with these system colors. I wish to know how.
  A concrete example: make a bitmap, for example some ellipses (like in the MS Internet Explorer 3.x), and display it as a TCoolBar background bitmap. If you have a standard color scheme, the bitmap’s (CoolBar’s) background will be clGray and the ellipses will have clSilver color. If you change your color scheme -- for example choosing Desert color scheme --, the same bitmap in the same program must be automatically sand-colored, not gray-colored. (If you have an Internet Explorer 3.x, you can see how it works).

Regards,
Adam Biro
0
 
LVL 4

Accepted Solution

by:
erajoj earned 150 total points
ID: 1336145
Hi,
Use the TImageList method "GetInstRes" and use "lrMap3DColors" in the "LoadFlags" parameter. Then your gray scales will be replaced with the 3D Windows colors.
Then transfer the image to whatever bitmap you want.

Like:
  MyImageList.GetInstRes( hInstance, rtBitmap, 'MYIMAGES', 16, [lrMap3DColors], clFuchsia );
  MyImageList.Draw( MyBitmap.Canvas, 0, 0, 0 );

The above code is not tested, and is just a simple example, but should work.

/// John
0
 
LVL 3

Expert Comment

by:vladika
ID: 1336146
There are functions CreateMappedBmp and CreateGrayMappedBmp
in the graphics.pas

function CreateMappedBmp(Handle: HBITMAP; const OldColors,
NewColors: array of TColor): HBITMAP;
{ This function will replace OldColors in Handle's colortable
with NewColors and return a new DDB which uses that color table.
For bitmap's with more than 256 colors (8bpp)
this function returns the original bitmap. }

function CreateGrayMappedBmp(Handle: HBITMAP): HBITMAP;
{ This function replaces the standard gray colors
in a bitmap with the system grays }

So, try it

type
  TForm1 = class(TForm)
    CoolBar1: TCoolBar;
    ToolBar1: TToolBar;
    ToolBar2: TToolBar;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    FCoolBarBitmap: TBitmap;
    procedure WMSysColorChange(var Message: TWMSysColorChange); message WM_SYSCOLORCHANGE;
    procedure MapCoolBarBitmap;
  end;

procedure TForm1.MapCoolBarBitmap;
begin
  // replace the standard gray colors in a bitmap
  // with the system grays
  CoolBar1.Bitmap.Handle := CreateGrayMappedBmp(FCoolBarBitmap.Handle);
end;

procedure TForm1.WMSysColorChange(var Message: TWMSysColorChange);
begin
  inherited;
  MapCoolBarBitmap;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  // save original CoolBar bitmap
  FCoolBarBitmap := TBitmap.Create;
  FCoolBarBitmap.Assign(Coolbar1.Bitmap);
  MapCoolBarBitmap;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FCoolBarBitmap.Free;
end;

0
 

Author Comment

by:biroadam
ID: 1336147
 To erajoy: Thank you, John, it is a good answer.

  To vladika: I liked your comment very much, and I choosed your version. I have only one further question:
  Creating a new bitmap with the CreateGrayMappedBmp function, isn’t neccessary to destroy it? You destroyed only that bitmap which was created by the TBitmap.Create method.
0
 
LVL 3

Expert Comment

by:vladika
ID: 1336148
>Creating a new bitmap with the CreateGrayMappedBmp function, isn’t neccessary to destroy it?

I think you are not neccessary to destroy it. Why?
Because you assign new bitmap's handle (created by
CreateGrayMappedBmp) to CoolBar1.Bitmap.Handle.
And Delphi automatically destroys new bitmap for you.
(when CoolBar1.Bitmap is destroyed).

0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

764 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