Einzelnen Beitrag anzeigen

Benutzerbild von Speedmaster
Speedmaster

Registriert seit: 4. Mär 2005
Ort: Karlsruhe
535 Beiträge
 
Delphi 2005 Personal
 
#1

TMyImage von Nightshade --> Transparente Bilder??

  Alt 17. Mär 2005, 20:11
Wie kann ich durchsichtige Bilder bei der Komponente von Nightshade realisieren??
Bisher habe ich folgendes versucht(Habe noch nie eine Komponente entwickelt, und habe daher praktisch null Ahnung):

Delphi-Quellcode:
unit MyImage;
 
interface
 
uses
  SysUtils, Classes, Controls, ExtCtrls, Graphics, Messages;
 
type TMyImage =class(TImage)
  private
    FOnMouseEnter: TNotifyEvent;
    FOnMouseLeave: TNotifyEvent;
    FMLPic: TPicture;
    FMEPic: TPicture;
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
    procedure SetMEPic(const Value: TPicture);
    procedure SetMLPic(const Value: TPicture);
  protected
  public
    TransparenySec: Boolean;
    constructor Create(AOwner : TComponent); override;
    destructor Destroy; override;
  published
    property OnMouseEnter : TNotifyEvent read FOnMouseEnter Write FOnMouseEnter;
    property OnMouseLeave : TNotifyEvent read FOnMouseLeave Write FOnMouseLeave;
    property MouseEnterPicture : TPicture read FMEPic write SetMEPic;
    property MouseLeavePicture : TPicture read FMLPic write SetMLPic;
end;
 
procedure Register;
 
implementation
 
procedure Register;
begin
  RegisterComponents('Zusätzlich', [TMyImage]);
end;
 
 
{ TMyImage } 
 
procedure TMyImage.CMMouseEnter(var Message: TMessage);
begin
  if Message.Msg=CM_MOUSEENTER then begin
    if csDesigning in ComponentState then begin
      if FMLPic.Bitmap <> NIL then picture.Bitmap.Assign(FMLPic.Bitmap);
    end
    else begin
      if FMEPic.Bitmap <> NIL then picture.Bitmap.Assign(FMEPic.Bitmap);
    end;
    if ( Assigned(FOnMouseEnter) ) then FOnMouseEnter(self);
    Picture.Bitmap.TransparentMode := tmFixed;
    Picture.Bitmap.TransparentColor := clBlack;
    Picture.Bitmap.Transparent := TransparenySec;
    repaint;
  end;
end;
 
procedure TMyImage.CMMouseLeave(var Message: TMessage);
begin
  if Message.Msg=CM_MOUSELEAVE then begin
    if FMLPic.Bitmap <> NIL then picture.Bitmap.Assign(FMLPic.Bitmap);
    if ( Assigned(FOnMouseLeave) ) then FOnMouseLeave(self);
    repaint;
  end;
end;
 
constructor TMyImage.Create(AOwner: TComponent);
begin
  inherited;
  FMLPic := TPicture.Create;
  FMEPic := TPicture.Create;
end;
 
destructor TMyImage.Destroy;
begin
  FreeAndNil(FMLPic);
  FreeAndNil(FMEPic);
  inherited;
end;
 
procedure TMyImage.SetMEPic(const Value: TPicture);
begin
  FMEPic.Bitmap.Assign(Value.Bitmap);
end;
 
procedure TMyImage.SetMLPic(const Value: TPicture);
begin
  FMLPic.Bitmap.Assign(Value.Bitmap);
end;
 
 
end.
Hier gibts den Orginal Code!

Und nein, mit Transparency im Objektinspektor auf "True" Funktioniert es nicht!
Felix K.
  Mit Zitat antworten Zitat