Solved

Palettes in graphic controls

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
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…

758 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

22 Experts available now in Live!

Get 1:1 Help Now