Solved

Palettes in graphic controls

Posted on 1998-11-18
1
175 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 22 hours left to enroll

632 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