Solved

clButtonX colors in CoolBar.Bitmap

Posted on 1998-08-16
11
294 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
Technology Partners: 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 50 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert a string into a TDateTime 5 79
Find and Replace Stream with 0s 8 86
Delphi: making a BW image transparent 10 136
Delphi Firemonkey : user drawing in window 3 56
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…

739 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