質問

少し問題があります。私はこのような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;

さて、ペイントボックスの親をform1に変更すると、ブラシが見えます。しかし、親がpanel1に変更された場合、何も起こりません。これを修正するにはどうすればよいですか?

前もって感謝します!

正しい解決策はありません

他のヒント

Tpanelはそもそも目に見えますか?

また、tpaintboxには一般のものがありません Brush プロパティ(おそらくあなたはtshapeを考えていますか?)。 Twincontrolはそうしますが、tpaintboxはTwincontrolの子孫ではありません。それはtgraphicControlの子孫です。

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

  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;

しかし、成功することなく..つまり、ペイントボックスコンポーネントをフォームにドロップすると、コードが実行されるように有効になっていますが、動的にtpaintboxを作成しています。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top