AGB  ·  Datenschutz  ·  Impressum  







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

Fehler beim Laden einer TBitmap-Property

Ein Thema von hanselmansel · begonnen am 22. Jul 2005 · letzter Beitrag vom 22. Jul 2005
 
Benutzerbild von hanselmansel
hanselmansel

Registriert seit: 23. Feb 2005
Ort: Kaiserslautern
279 Beiträge
 
Delphi 2009 Enterprise
 
#7

Re: Fehler beim Laden einer TBitmap-Property

  Alt 22. Jul 2005, 10:59
DANKE!!!

@ BlackJack: Ich habe die Exceptions weggestrichen und die TBitmaps im Constructor "created". Wahrscheinlich war genau das der Fehler!

@ Muetze1: Danke für den Hinweis! War mir nicht darüber im Klaren, hab die Variablen jetzt aber in "private" deklariert.

Nochmals vielen Dank!

hanselmansel

P.S.: Falls es irgendjemanden interessiert/ Sollte irgendjemand eine ähnliche Fragestellung gehabt haben:
Delphi-Quellcode:

unit MyButtons;

interface

uses
  SysUtils, Classes, Controls, Graphics;

type
  Wechselbutton = class(TCustomControl)
  private
    { Private-Deklarationen }
    FOnMouseDown :TMouseEvent;
    Img_normal :TBitmap;
    Img_MouseDown :TBitmap;
    Img_disabled :TBitmap;
    b_Enabled :Boolean;
    b_MouseDown :Boolean;
  protected
    { Protected-Deklarationen }
    Procedure Paint; override;
    Procedure SetNormImg(Img :TBitmap);
    Procedure SetMoDoImg(Img :TBitmap);
    Procedure SetDisaImg(Img :TBitmap);

  public
    { Public-Deklarationen }
    constructor Create(Owner: TComponent); override;

  published
    { Published-Deklarationen }
    Property OnMouseDown:TMouseEvent read FOnMouseDown write FOnMouseDown;

    Property Surface_Normal :TBitmap read Img_normal write SetNormImg;
    Property Surface_MouseDown :TBitmap read Img_MouseDown write SetMoDoImg;
    Property Surface_Disabled :TBitmap read Img_disabled write SetDisaImg;
  end;

procedure Register;

implementation

constructor Wechselbutton.Create(Owner: TComponent);
begin
inherited Create(Owner);
b_Enabled := True;
b_MouseDown := False;
Img_normal := TBitmap.Create;
Img_MouseDown := TBitmap.Create;
Img_disabled := TBitmap.Create;
end;

procedure Wechselbutton.Paint;
begin
If b_Enabled then
  Begin
  If b_MouseDown then
    Begin
    {Width := Img_MouseDown.Width;
    Height := Img_MouseDown.Height; }

    Canvas.Draw(0,0,Img_MouseDown);
    End
  Else
    Begin
    {Width := Img_normal.Width;
    Height := Img_normal.Height;}

    Canvas.Draw(0,0,Img_normal);
    End;
  End
Else
  Begin
  Width := Img_disabled.Width;
  Height := Img_disabled.Height;
  Canvas.Draw(0,0,Img_disabled);
  End;
end;

Procedure Wechselbutton.SetNormImg(Img :TBitmap);
begin
if Img <> Img_normal then
  begin
  Img_normal.Assign(Img);
  Update;
  end;
end;

Procedure Wechselbutton.SetMoDoImg(Img :TBitmap);
begin
if Img <> Img_MouseDown then
  begin
  Img_MouseDown.Assign(Img);
  Update;
  end;
end;

Procedure Wechselbutton.SetDisaImg(Img :TBitmap);
begin
if Img <> Img_disabled then
  begin
  Img_disabled.Assign(Img);
  Update;
  end;
end;


//*****************
//*****************
//*****************

procedure Register;
begin
  RegisterComponents('Beispiele', [MyButtons.Wechselbutton]);
end;

end.
Es gibt nur sehr wenige Probleme auf dieser Welt, die sich nicht mit einigen hundert Gramm Sprengstoff lösen ließen.
  Mit Zitat antworten Zitat
 


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 17:58 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz