Solved

clButtonX colors in CoolBar.Bitmap

Posted on 1998-08-16
11
287 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
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 10

Expert Comment

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

Regards,
Viktor Ivanov
0
 

Author Comment

by:biroadam
Comment Utility
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
Comment Utility
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
 

Author Comment

by:biroadam
Comment Utility
 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
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 10

Expert Comment

by:viktornet
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
 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
Comment Utility
>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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

771 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

14 Experts available now in Live!

Get 1:1 Help Now