ich habe eine Komponente vo TCustomControl abgeleitet,
<pre>
TStatus = (stat1,stat2,stat3,stat4);
TKompo = class(TCustomControl);
private
FStatus :TStatus;
procedure SetStatus(value:TStatus)
procedure KompoPaint(HBm:TBitmap; Prect:TRect)
protected
procedure Paint;override;
public
constructor create(aowner);
published
property Status : TStatus read FStatus write SetStatus;
implementation
procedure Kompo.setstatus(value: TStatus)
begin
If value<>FStatus then
begin
FStatus := value;
refresh;
end;
end;
procedure Kompo.Paint;
var
hbm :TBitmap;
Paintrect: TRect;
SaveMode:Longint;
begin
hbm:=TBitmap.create;
try
hbm.Width:= width;
hbm.Height:= height;
Prect:=ClientRect;
KompoPaint(HBM,Prect);
SaveMode:=Canvas.CopyMode;
Canvas.CopyMode:=cmSrcCopy;
Canvas.Draw(0,0,hbm);
Canvas.CopyMode:=SaveMode;
finally
HBM.Free;
end;end;
procedure Kompo.KompoPaint(HBm:TBitmap;PRect:TRect);
begin
with Hbm.canvas.pen do
begin
case FStatus of
stat1 : color := clred;
stat2 : color := clyellow;
stat3 : color := clblue;
stat4 : color := clgreen;
end;
end;
with HB.Canvas do
begin
pen.width:=1;
rectangle(0,0,8,13);
Pen.Width:=2;
moveto(4,3);
lineto(4,7);
moveto(4,10);
Lineto(4,10);
end;
end;
</pre>
nun habe ich folgendes Problem, wenn ich aus der Anwendung den Status ändere geht dies auch Problemlos. nur es müßte ja bei refresh die Komponente neu gezeichnet werden.das programm geht aus der Kompo raus und springt dann wieder rein mit 'stat1', so dass ich den Status optisch nicht ändern kann,
was ist das Problem?
mfg raik
<pre>
TStatus = (stat1,stat2,stat3,stat4);
TKompo = class(TCustomControl);
private
FStatus :TStatus;
procedure SetStatus(value:TStatus)
procedure KompoPaint(HBm:TBitmap; Prect:TRect)
protected
procedure Paint;override;
public
constructor create(aowner);
published
property Status : TStatus read FStatus write SetStatus;
implementation
procedure Kompo.setstatus(value: TStatus)
begin
If value<>FStatus then
begin
FStatus := value;
refresh;
end;
end;
procedure Kompo.Paint;
var
hbm :TBitmap;
Paintrect: TRect;
SaveMode:Longint;
begin
hbm:=TBitmap.create;
try
hbm.Width:= width;
hbm.Height:= height;
Prect:=ClientRect;
KompoPaint(HBM,Prect);
SaveMode:=Canvas.CopyMode;
Canvas.CopyMode:=cmSrcCopy;
Canvas.Draw(0,0,hbm);
Canvas.CopyMode:=SaveMode;
finally
HBM.Free;
end;end;
procedure Kompo.KompoPaint(HBm:TBitmap;PRect:TRect);
begin
with Hbm.canvas.pen do
begin
case FStatus of
stat1 : color := clred;
stat2 : color := clyellow;
stat3 : color := clblue;
stat4 : color := clgreen;
end;
end;
with HB.Canvas do
begin
pen.width:=1;
rectangle(0,0,8,13);
Pen.Width:=2;
moveto(4,3);
lineto(4,7);
moveto(4,10);
Lineto(4,10);
end;
end;
</pre>
nun habe ich folgendes Problem, wenn ich aus der Anwendung den Status ändere geht dies auch Problemlos. nur es müßte ja bei refresh die Komponente neu gezeichnet werden.das programm geht aus der Kompo raus und springt dann wieder rein mit 'stat1', so dass ich den Status optisch nicht ändern kann,
was ist das Problem?
mfg raik
Comment