Reputation:
I'm using Delphi7 under Windows XP. How would I go about adding a "Delete" toolbutton to the Delphi TOpenPictureDialog component? Is there any way to get the dialog into the Designer to add the button and its behavior?
Upvotes: 4
Views: 1096
Reputation: 1364
You can write your "own" OpenDialog and inherit this new Class from TOpenPictureDialog. There is an (old) freeware component named "PBOpenPreviewDialog" which does exactly this (from TOpenDialog), maybe you can take that component as an example?
You can find the webpage at: http://bak-o-soft.dk/Delphi/PBFolderDialog.aspx
And a download link for the component here: http://bak-o-soft.dk/Download.asgx.ashx/Delphi/PBFolderDialog.zip
Upvotes: 0
Reputation: 136391
you can add a new button to the TOpenPictureDialog
but not getting the dialog into the Designer, you must do it in runtime.
check this sample
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;
and the result is
Upvotes: 5