0

少し問題があります。次のように TPanel に TPaintBox を作成しようとしています。

procedure TForm1.mkPaint(S: string);
var PB: TPaintBox;
begin
  PB := TPaintBox.Create(Self);
  with PB do 
  begin
    Parent := Panel1;
    Visible := True;
    Name := S;
    Height := 100;
    Width := 100;
    Left := 8;
    Top := 8;
    // ParentColor := False;
    Brush.Style := bsSolid;
    Brush.Color := $00000000;
  end;
  Application.ProcessMessages;
end;

ここで、PaintBox の Parent を Form1 に変更すると、ブラシが表示されます。しかし、親を Panel1 に変更すると、何も起こりません。どうすればこれを修正できますか?

前もって感謝します!

4

2 に答える 2

0

TPanel は最初から表示されていますか?

また、TPaintBox には publicBrushプロパティがありません (おそらく TShape を考えているのでしょうか?)。TWinControl にはありますが、TPaintBox は TWinControl の子孫ではありません。これは TGraphicControl の子孫です。

于 2010-11-18T03:14:48.673 に答える
0

ええ、それは私の間違いでした。コードを次のように変更しました。

  pb := TPaintBox.Create(self);
  with pb do begin
    Parent := Form1;
    Visible := true;
    Top := 1;
    Left := 1;
    Width := 250;
    Height := 100;
    ParentColor := false;
    Canvas.Brush.Color := clBlack;
    Canvas.Font.Size := 12;
    Canvas.Font.Color := clWhite;
    Canvas.FillRect(ClientRect);
    Canvas.TextOut(1, 1, 'test');
  end;

しかし、成功しませんでした..つまり、PaintBoxコンポーネントをフォームにドロップすると、コードは本来のように有効になりますが、TPaintBoxを動的に作成します....ダンノ。

于 2010-11-18T13:23:07.900 に答える