Тут происходят странные вещи. С PaintBox1 всё нормально. А P при первом нажатии на SpeedButton не выводит графическую информацию. Вернее, выводит и тут же стирает. Даже можно заметить промелькивание. При последующих нажатиях выводит нормально :o
В чём тут может быть дело??
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, ExtCtrls, TreeWork;
type
TForm1 = class(TForm)
SpeedButton1: TSpeedButton;
PaintBox1: TPaintBox;
procedure SpeedButton1Click(Sender: TObject);
procedure Create(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
P:TPaintBox;
implementation
{$R *.dfm}
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
PaintBox1.Canvas.TextOut(10,10,'1000');
PaintBox1.Canvas.Ellipse(10,10,20,20);
With P do
begin
Height:=100;
Width:=100;
Left:=20;
Top:=20;
Cursor:=crHandPoint;
Color:=clYellow;
ParentColor:=false;
ParentFont:=false;
Font.Color:=clBlack;
Font.Size:=8;
Canvas.Pen.Color:=clRed;
Canvas.Pen.Style:=psSolid;
Canvas.Brush.Style:=bsSolid;
Canvas.Brush.Color:=clYellow;
Canvas.Rectangle(0,0,Height,Width);
Canvas.TextOut(10,10,'1000');
Canvas.Ellipse(10,10,20,20); {здесь при отлаживании текст в прямоугольнике виден на экране}
end;
end; //а на выходе из процедуры исчезает
procedure TForm1.Create(Sender: TObject);
begin
P:=TPaintBox.Create(Form1);
P.Parent:=Form1;
end;
end.