Хоткей для кнопки Export to PDF в Preview
Раздел: FastReport 4.0
Здравствуйте.
Как создать хоткей для кнопки Export to PDF в Preview (четвёртая слева на скриншоте)?
Комментарии
В FR 4 добраться до свойств кнопки можно так (на примере с переопределением OnClick):
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, frxClass, frxExportPDF, frxPreview, frxDsgnIntf, Menus;
type
TForm1 = class(TForm)
frxReport1: TfrxReport;
frxPDFExport1: TfrxPDFExport;
SaveDialog1: TSaveDialog;
procedure FormCreate(Sender: TObject);
procedure frxReport1Preview(Sender: TObject);
procedure PDFExport(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.PDFExport(Sender: TObject);
begin
if SaveDialog1.Execute then
begin
frxPDFExport1.FileName:=SaveDialog1.FileName;
TfrxPreview(frxReport1.Preview).Export(frxPDFExport1);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
frxReport1.ShowReport;
end;
procedure TForm1.frxReport1Preview(Sender: TObject);
var i, j, mi: integer;
begin
TfrxPreviewForm(frxReport1.PreviewForm).PdfB.OnClick:=PDFExport;
for i := 0 to frxExportFilters.Count - 1 do
begin
if TfrxCustomExportFilter(frxExportFilters[i].Filter).ClassName = 'TfrxPDFExport' then
mi:=i;
end;
TfrxPreviewForm(frxReport1.PreviewForm).ExportPopup.Items[mi].OnClick:=PDFExport;
for i:=0 to TfrxPreviewForm(frxReport1.PreviewForm).RightMenu.Items.Count-1 do
begin
if TfrxPreviewForm(frxReport1.PreviewForm).RightMenu.Items[i].Caption=TfrxPreviewForm(frxReport1.PreviewForm).ExportB.Hint then
begin
for j:=0 to TfrxPreviewForm(frxReport1.PreviewForm).RightMenu.Items[i].Count-1 do
if TfrxPreviewForm(frxReport1.PreviewForm).RightMenu.Items[i][j].Caption=TfrxPreviewForm(frxReport1.PreviewForm).ExportPopup.Items[mi].Caption then
TfrxPreviewForm(frxReport1.PreviewForm).RightMenu.Items[i][j].OnClick:=PDFExport;
end;
if TfrxPreviewForm(frxReport1.PreviewForm).RightMenu.Items[i].Caption=TfrxPreviewForm(frxReport1.PreviewForm).PdfB.Hint then
TfrxPreviewForm(frxReport1.PreviewForm).RightMenu.Items[i].OnClick:=PDFExport;
end;
end;
end.