gpt4 book ai didi

delphi - 向 TOpenPictureDialog 添加按钮

转载 作者:行者123 更新时间:2023-12-03 15:27:50 24 4
gpt4 key购买 nike

我在Windows XP下使用Delphi7。我将如何向 Delphi TOpenPictureDialog 组件添加“删除”工具按钮?有没有办法让对话框进入设计器以添加按钮及其行为?

最佳答案

您可以向TOpenPictureDialog添加一个新按钮,但不能将对话框放入设计器中,您必须在运行时执行此操作。

检查此示例

procedure TForm1.FormCreate(Sender: TObject);
var
FDeleteButton : TSpeedButton;
FPreviewButton : TSpeedButton;
begin
FPreviewButton := TSpeedButton(OpenPictureDialog1.FindComponent('PreviewButton'));
FDeleteButton := TSpeedButton.Create(OpenPictureDialog1);
FDeleteButton.SetBounds(107, 1, 23, 22);
FDeleteButton.Parent := FPreviewButton.Parent;
FDeleteButton.NumGlyphs:=2;
FDeleteButton.Glyph.LoadFromResourceName(HInstance, 'BBABORT');
FDeleteButton.Name := 'DeleteButton';
FDeleteButton.OnClick := DeleteBtnClick;
end;

procedure TForm1.DeleteBtnClick(Sender: TObject);
begin
//here you must implement the delete logic
ShowMessage('Hello from delete button');
end;

结果是

enter image description here

关于delphi - 向 TOpenPictureDialog 添加按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5766215/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com