Solved

Palettes in graphic controls

Posted on 1998-11-18
1
171 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10 Round Image 2 128
Run video youtube webbrowse 10 61
TServerSocket - file via sendbuf or Text via sendtext ? 1 53
Firemonkey webbrowser scrollbars ? 1 38
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 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