Solved

Palettes in graphic controls

Posted on 1998-11-18
1
170 Views
Last Modified: 2010-04-04
I want to use more than the standard palette in graphic controls more precise I want them to be 16bit. Is that possible. I guess you can set the palette if you want 256 colours but how to set it to be true color?

More spesific I want a TListBox with 16bit bitmap on it.. How can I do that?
0
Comment
Question by:mortenmo
1 Comment
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
ID: 1347265
mortenmo

Here is a simple component that does that but it is still in beta so you may need to get your hands dirty...

unit TransListBox;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TTransListBox = class(TListbox)
  private
    FBitmap : TBitmap;
  protected
    Constructor Create (AnOwner : TComponent); overRide;
    Destructor Destroy; Override;
    Procedure DefaultHandler (Var Message); Override;
    Procedure WM_EraseBkGnd(Var Msg : TWMEraseBkGnd); Message WM_EraseBkGnd;
    Procedure SetBitmap(NewBitmap : TBitmap);
  public
 
  published
   
    Property Bitmap : TBitmap Read fBitmap Write SetBitmap;
  end;

procedure Register;

implementation

Constructor TTransListbox.Create (AnOwner : TComponent);
Begin
  Inherited Create(AnOwner);
  FBitmap := TBitmap.Create;
  Color := clNone;  // Setting to clWindow causes the strange behavior we are all familiar with.
End;

Destructor TTransListbox.Destroy;
Begin
  fBitmap.Free;
  Inherited Destroy;
End;

Procedure TTransListbox.SetBitmap(NewBitmap : TBitmap);
Begin
  FBitmap.Assign(NewBitmap);
End;

Procedure TTransListbox.DefaultHandler (Var Message);
Begin
  Inherited DefaultHandler(Message);
  With TMessage(Message) Do
  Begin
    Case Msg Of
      cn_CTLCOLORMSGBOX..cn_CTLCOLORSTATIC:
        begin
          SetBkMode(WParam, Transparent);
        end;
    End;
  End;
End;

Procedure TTransListbox.WM_EraseBkGnd(Var Msg : TWMEraseBkGnd);
Var
  Canvas : TCanvas;
Begin
  Inherited;
   Msg.Result := 0;
// Draw your own custom background here.
  Canvas := TCanvas.Create;
  Canvas.Handle := msg.DC;
  Canvas.Draw(0,0,fBitmap);
  Canvas.Free;
   Msg.Result := 1;
End;

procedure Register;
begin
  RegisterComponents('BoRiS', [TTransListbox]);
end;

end.


This component will allow you to choose a picture for the background of the listbox, but like i said this is still in beta and my be abit buggy, but you will get the general idea form here...

Later
BoRiS
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 100
Delphi Mdi application Child forms get behind control 7 163
Unique identifier on a terminal server (rdp) 4 46
Delphi...Split view - idea? 1 42
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

19 Experts available now in Live!

Get 1:1 Help Now