Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

ShowFileOpenDialog:

edited February 2017 in End User
Is it possible to override the TppTemplate.ShowFileOpenDialog function?

Thanks,

Ken

Comments

  • edited February 2017
    Hi Ken,

    There is a Report.Template.OnCreateDialog event that fires after the dialog
    is created. You can type cast the aDialog parameter and set its properties.

    Example:

    ppReport1.Template.OnCreateDialog := ehReportTemplate_CreateDialog;



    procedure TForm1.ehReportTemplate_CreateDialog(Sender, aDialog: TObject);
    var
    lOpenDialog: TOpenDialog;
    begin

    if aDialog is TOpenDialog then
    begin

    lOpenDialog:= TOpenDialog(aDialog);

    // set dialog properties here...

    end
    else if (aDialog is TSaveDialog) then
    begin


    end;


    end;


    Another approach is to implement the TppDesigner.OnCustomOpenDoc and
    OnCustomSaveDoc, OnCustomSaveQueryDoc events. These events require that you
    implement the code to load and save providing complete control;



    Best regards,

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2017
    Thanks Nard,

    The 2nd approach seems exactly what I am looking for.

    Thanks,

    Ken
  • edited February 2017
    Hi Nard,

    I can't seem to get this to work.

    I have put my code in the TppDesigner.OnCustomOpenDoc event but this is
    not being called when I click on File>Load from File in the designers
    menu. It is still calling TppTemplate.ShowFileOpenDialog.

    Regards,

    Ken
  • edited February 2017
    Hi Ken,

    My recollection of OnCustomOpenDoc was not accurate. That event enables
    custom template loading, but not the dialog. It fires after the dialog.

    Here's another approach...

    Assign a custom event-handler to the File | Open menu item click. Below is a
    simple example I adapted from this rbWiki 'How To'

    http://www.digital-metaphors.com/rbWiki/End-User/Designer/How_To...Customize_Designer_Menu_and_Toolbars


    Example:

    procedure TForm1.FormCreate(Sender: TObject);
    var
    lMenuBar: TppMenuBar;
    lDesignerMenu: TppDesignerMenu;
    begin

    lMenuBar := ppDesigner1.Form.MainMenu;

    if (lMenuBar is TppDesignerMenu) then
    begin
    lDesignerMenu := TppDesignerMenu(lMenuBar);
    lDesignerMenu.FileMenu.Open.OnClick := ehFileMenu_OpenClick;
    end;

    end;

    procedure TForm1.ehFileMenu_OpenClick(Sender: TObject);
    begin
    ShowMessage('ehFileMenu_OpenClick');
    end;




    Best regards,

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2017

    Nard,

    Thanks. It was the LoadFrom/SaveTo File OnClick events that I had to
    change:

    lDesignerMenu.FileMenu.LoadFromFile.OnClick:=LoadFromFile;
    lDesignerMenu.FileMenu.SaveToFile.OnClick:=SaveToFile;

    Regards,

    Ken
This discussion has been closed.