Hi!
I have another issue regarding an sPanel with an OnPaint routine assigned.
Deriving a class from sPanel I have a constructor like:
CODE
Constructor TMyPanel.Create(AOwner: TWinControl);
begin
inherited Create(AOwner);
Parent := AOwner;
Caption := 'I am a Panel';
newButton := TsSpeedButton.Create(Self);
newButton.Parent := Self;
newButton.ShowHint := True;
newButton.Hint := 'Hello';
newButton.Caption := 'Hello';
OnPaint := myPaint;
The problem is, that in some situations myPaint draws over the button. I was able to reproduce this behaviour with myButton.ShowHint := True
I also found out, that the panels caption is drawn correctly which led me to the following solution:
CODE
procedure TsPanel.OurPaint;
var
Canv: TCanvas; //Added this
begin
//some Code
// The original code
//if DC = 0 then WriteText(R, Canvas) else WriteText(R, nil, DC);
//if Assigned(FOnPaint) then FOnPaint(Self, Canvas);
// My changes
if DC = 0 then
begin
Canv := Canvas;
end
else begin
Canv := TCanvas.Create;
Canv.Handle := DC;
Canv.Font.Assign(Font);
Canv.Brush.Style := bsClear;
end;
WriteText(R, Canv);
if Assigned(FOnPaint) then FOnPaint(Self, Canv);
if DC <> 0 then
begin
Canv.Free;
end;
Cheers,
Clemens