AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Transparente Listbox

Ein Thema von Manzoni · begonnen am 5. Mai 2004 · letzter Beitrag vom 11. Mai 2004
Antwort Antwort
Seite 1 von 2  1 2      
Benutzerbild von Manzoni
Manzoni

Registriert seit: 15. Feb 2004
Ort: Berlin
120 Beiträge
 
Delphi 7 Enterprise
 
#1

Transparente Listbox

  Alt 5. Mai 2004, 16:14
Hi DP'ler,

ich suche ganz verzweifelt eine transparente Listbox-Komponente. Hat bzw. kennt einer von euch eine solche Komponente oder weiss wie man so etwas realisieren kann? Danke im Voraus.
Bob
  Mit Zitat antworten Zitat
shmia

Registriert seit: 2. Mär 2004
5.508 Beiträge
 
Delphi 5 Professional
 
#2

Re: Transparente Listbox

  Alt 5. Mai 2004, 16:59
Im folgenden eine transparente Listbox (ungetestet):
Delphi-Quellcode:
type
  TTransparentListBox = class(TListBox)
  private
    procedure WMEraseBkgnd(var Message: TWmEraseBkgnd); message WM_ERASEBKGND;
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  end;

implementation

procedure TTransparentListBox.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.ExStyle:= Params.ExStyle or WS_EX_TRANSPARENT;
end;

procedure TTransparentListBox.WMEraseBkgnd(var Message: TWmEraseBkgnd);
begin
  // in this case, we want to intercept the windows message. if we would want to
  // pass the message to the ancestor classes, we could use the keyword
  // "inherited" without the procedure name. example:
  // inherited;
  Message.Result := 1;
end;
PS: Verschwende deine Zeit nicht mit nutzlosen optischen Gimmicks.
Andreas
  Mit Zitat antworten Zitat
Benutzerbild von Manzoni
Manzoni

Registriert seit: 15. Feb 2004
Ort: Berlin
120 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: Transparente Listbox

  Alt 5. Mai 2004, 19:31
danke für die Antwort, hat aber leider nicht funktioniert
Hab schon diesen Tipp ausprobiert, klappt aber leider nicht mit nem Bild darunter worauf es mir ankommt.
Bob
  Mit Zitat antworten Zitat
Benutzerbild von Manzoni
Manzoni

Registriert seit: 15. Feb 2004
Ort: Berlin
120 Beiträge
 
Delphi 7 Enterprise
 
#4

Re: Transparente Listbox

  Alt 7. Mai 2004, 12:28
hat keiner ne idee?
Bob
  Mit Zitat antworten Zitat
Benutzerbild von glkgereon
glkgereon

Registriert seit: 16. Mär 2004
2.287 Beiträge
 
#5

Re: Transparente Listbox

  Alt 7. Mai 2004, 19:06
was heisst transparent?
kann man das nit bei ner normalen ListBox einstellen
mom, muss ma eben an nem, anderen puti gucken...
»Unlösbare Probleme sind in der Regel schwierig...«
  Mit Zitat antworten Zitat
Benutzerbild von glkgereon
glkgereon

Registriert seit: 16. Mär 2004
2.287 Beiträge
 
#6

Re: Transparente Listbox

  Alt 7. Mai 2004, 19:15
ne, hab ich nix zu gefunden

wobei man könnte mal gucken, ob man bei der farbe was tricksen kann, fürchte aber nein
»Unlösbare Probleme sind in der Regel schwierig...«
  Mit Zitat antworten Zitat
Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#7

Re: Transparente Listbox

  Alt 7. Mai 2004, 19:24
Hi,

Habe mal eine TransparentListBox Komponente gefunden.
So wie sie jetzt ist funktioniert sie aber nur für nicht-scrollende Listboxen.


Delphi-Quellcode:
unit TransparentListBox;

(*
*
*  Written by Walter Irion (CIS 114254, 2455) after the THotSpot
*  sample component that Arne Schäpers presented in the German
*  c't magazine (issue 6/1996, pp. 286 ff.).
*
*  TTransparentListBox is far from being a universal solution:
*  it does not prevent Windows' scrolling mechanism from
*  shifting the background along with scrolled listbox lines.
*  Moreover, the scroll bar remains hidden until the keyboard
*  is used to change the selection, and the scroll buttons
*  become visible only when clicked.
*
*  To break it short: TTransparentListBox is only suitable
*  for non-scrolling lists.
*
*  In fact it must be possible to write a listbox component
*  that handles scrolling correctly. But my essays to intercept
*  EM_LINESCROLL messages were fruitles, even though I tried
*  subclassing via WndProc.
*
*  A solution for transparent TEdit and TMemo controls is
*  introduced in issue 9/1996 of the c't magazine, again
*  by Arne Schäpers. But these are outright monsters with
*  wrapper windows to receive notification messages as well
*  as so-called pane windows that cover the actual control's
*  client area and display its content.
*
*  Previous issues of the c't magazine can be ordered from:
*
*    c't-Kopierservice
*    Helstorfer Str. 7
*    30625 Hannover, Germany
*
*  They expect a crossed cheque amounting to DM 14,00
*  to be included with your order, but I don't know about
*  international orders.
*
*)


interface

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

type
  TTransparentListBox = class(TListBox)
  private
    { Private declarations }
  protected
    { Protected declarations }
    procedure CreateParams(var Params: TCreateParams); override;
    procedure WMEraseBkgnd(var Msg: TWMEraseBkgnd); message WM_ERASEBKGND;
    procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
      override;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  published
    { Published declarations }
    property Style default lbOwnerDrawFixed;
    property Ctl3D default False;
    property BorderStyle default bsNone;
  end;

procedure Register;

implementation

constructor TTransparentListBox.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Ctl3D := False;
  BorderStyle := bsNone;
  Style := lbOwnerDrawFixed; // changing it to lbStandard results
                              // in loss of transparency
end;

procedure TTransparentListBox.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.ExStyle := Params.ExStyle or WS_EX_TRANSPARENT;
end;

procedure TTransparentListBox.WMEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
  Msg.Result := 1; // Prevent background from getting erased
end;

procedure TTransparentListBox.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
  tlbVisible: Boolean;
begin
  tlbVisible := (Parent <> nil) and IsWindowVisible(Handle); // Check for visibility
  if tlbVisible then ShowWindow(Handle, SW_HIDE); // Hide-Move-Show strategy ...
  inherited SetBounds(ALeft, ATop, AWidth, AHeight); // ... to prevent background ...
  if tlbVisible then ShowWindow(Handle, SW_SHOW); // ... from getting copied
end;

procedure TTransparentListBox.DrawItem(Index: Integer; Rect: TRect; State:
  TOwnerDrawState);
var
  FoundStyle: TBrushStyle;
  R: TRect;

begin

  FoundStyle := Canvas.Brush.Style; // Remember the brush style

  R := Rect; // Adapt coordinates of drawing rect ...
  MapWindowPoints(Handle, Parent.Handle, R, 2); // ... to parent's coordinate system
  InvalidateRect(Parent.Handle, @R, True); // Tell parent to redraw the item position
  Parent.Update; // Trigger instant redraw (required)

  if not (odSelected in State) then begin // If an unselected line is being handled
    Canvas.Brush.Style := bsClear; // use a transparent background
  end else begin // otherwise, if the line needs to be highlighted,
    Canvas.Brush.Style := bsSolid; // some colour to the brush is essential
  end;

  inherited DrawItem(Index, Rect, State); // Do the regular drawing and give component users ...
                                          // ... a chance to provide an OnDrawItem handler

  Canvas.Brush.Style := FoundStyle; // Boy-scout rule No. 1: leave site as you found it

end;

procedure Register;
begin
  RegisterComponents('Samples', [TTransparentListBox]);
end;

end.
Thomas
  Mit Zitat antworten Zitat
CalganX

Registriert seit: 21. Jul 2002
Ort: Bonn
5.403 Beiträge
 
Turbo Delphi für Win32
 
#8

Re: Transparente Listbox

  Alt 7. Mai 2004, 19:27
Hi toms,
Zitat von Manzoni:
... Hab schon diesen Tipp ausprobiert, klappt aber leider nicht...


Chris
  Mit Zitat antworten Zitat
Benutzerbild von toms
toms
(CodeLib-Manager)

Registriert seit: 10. Jun 2002
4.648 Beiträge
 
Delphi XE Professional
 
#9

Re: Transparente Listbox

  Alt 7. Mai 2004, 19:28
Oops Sorry, bei mir klappt's eben.
Thomas
  Mit Zitat antworten Zitat
Benutzerbild von glkgereon
glkgereon

Registriert seit: 16. Mär 2004
2.287 Beiträge
 
#10

Re: Transparente Listbox

  Alt 7. Mai 2004, 19:29
brauchst dus denn umbedingt?
so, wies aussieht, wirst du drauf verzichten müssen..
»Unlösbare Probleme sind in der Regel schwierig...«
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:15 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz