Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Palettes in graphic controls

Posted on 1998-11-18
1
Medium Priority
?
177 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 200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

926 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