Hallo
Äh... TEdit hat kein OnPaint oder?
Aktuell kann ich euch folgendes Zeigen.
Anregungen Verbesserungen sind immer Herzlich Willkommen...
Delphi-Quellcode:
unit ImageEdit;
interface
uses
SysUtils, Classes, Controls, StdCtrls, ExtCtrls, Windows, Messages, Graphics;
type
TImageEdit =
class(TEdit)
private
{ Private-Deklarationen }
fBMP : TBitmap ;
fFocus : Boolean ;
procedure WMPaint(
var msg: TWMPaint);
message WM_PAINT;
procedure WMKillFocus(
var Message: TWMSetFocus);
message WM_KillFocus ;
procedure WMSetFocus(
var Message: TWMSetFocus);
message WM_SetFocus ;
protected
{ Protected-Deklarationen }
public
{ Public-Deklarationen }
constructor Create(aOwner: TComponent);
override;
destructor Destroy;
override ;
published
{ Published-Deklarationen }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
easyLEARN', [TImageEdit]);
end;
{ TImageEdit }
constructor TImageEdit.Create(aOwner: TComponent);
begin
Inherited ;
fBMP := TBitmap.Create ;
fBMP.LoadFromFile('
c:\temp\logo_s4u.bmp') ;
end;
destructor TImageEdit.Destroy;
begin
fBMP.Free ;
Inherited ;
end;
procedure TImageEdit.WMSetFocus(
var Message: TWMSetFocus);
begin
Inherited;
fFocus := True ;
Color := clRed ;
// Hack zum Aufrufen von WMPaint
Color := clWhite ;
// Hack zum Aufrufen von WMPaint
end;
procedure TImageEdit.WMKillFocus(
var Message: TWMSetFocus);
begin
Inherited;
fFocus := False ;
Color := clRed ;
// Hack zum Aufrufen von WMPaint
Color := clWhite ;
// Hack zum Aufrufen von WMPaint
end;
procedure TImageEdit.WMPaint(
var msg: TWMPaint);
var dc : hdc;
canvas :tcanvas;
begin
Inherited ;
if fBMP =
NIL then EXIT ;
if NOT fFocus
then
begin
if Length(Text) = 0
then
begin
dc := getdc(Self.Handle);
canvas:= tcanvas.Create ;
Canvas.Handle :=
DC;
Canvas.Draw(-5, -3, fBMP);
end;
end;
end;
end.