在TCustomRichEdit上方添加一个速度按钮

A1r*_*Pun 0 delphi components derived custom-controls

我正在尝试创建一个TCustomRichEdit,上面有一些速度按钮.我怎样才能完成这个行为?组件的高度需要是按钮+ richedit.

[B][I][U]
+-------+
|A1REdit|
|       |
+-------+
Run Code Online (Sandbox Code Playgroud)

目前我有以下代码:

private
  FBoldButton: TSpeedButton;

constructor TA1RichEdit.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  FBoldButton := TSpeedButton.Create(Self);
  FBoldButton.Parent := Self;
end;

destructor TA1RichEdit.Destroy;
begin
  FreeAndNil(FBoldButton);

  inherited;
end;
Run Code Online (Sandbox Code Playgroud)

这描绘了richedit上的速度按钮(因为richedit是父级),我需要按钮位于richedit之上.在这段代码之后,richedit并没有像它应该的那样绘画.

Ste*_*nke 5

用一个TToolbar.

还要在表单上添加一个TImageList和一个TActionList.

将ImageList分配给ActionList和ToolBar.

然后,您可以向ActionList添加一些所谓的标准操作("新操作"按钮上的下拉菜单).

Format您将找到的类别中TRichEditBold,TRichEditItalicTRichEditUnderline.选择它们并单击OK.

然后,在工具栏中添加3个工具按钮,并将操作分配给它们.

当选择具有此状态的内容并自动设置粗体,斜体或下划线时,所有类似于按下状态的操作都将在不编写任何代码的情况下进行处理.