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

Replacing the Preview Data dialog.

edited February 2011 in End User
Hi,

I'm trying to replace the standard Preview Data dialog which is accessed
from the preview button
on the table dataview windows in the Data tab.

I've followed the example on the RB wiki for replacing the print dialog but
I'm having some issues getting my custom dialog to display.

I've added my new unit to the project and registered the class in the init
and finalization sections. (See below)

I can see when I run my app, the initialization section gets run but when I
attempt to open the dialog by clicking on the preview button, nothing
happens. Not even the standard dialog displays.

I've placed a breakpoint on the new dialog constructor but it never seems to
get called.
Is there some detail I am missing?

Thanks,

Chris Hedges



//my class
TmyPreviewDataDialog = class(TdaCustomPreviewDataDialog)
blah
blah

//register the new form
initialization

ppRegisterForm(TdaCustomPreviewDataDialog, TmyPreviewDataDialog);

finalization

ppUnRegisterForm(TdaCustomPreviewDataDialog);

Comments

  • edited February 2011
    I tried a simple test here and it worked fine. Here is my code....

    unit Unit2;

    interface

    uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs,
    ppForms,
    daForms, daDataView;

    type
    TmyDataPreview = class(TdaCustomPreviewDataDialog)
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    myDataPreview: TmyDataPreview;

    implementation

    {$R *.dfm}


    initialization

    ppRegisterForm(TdaCustomPreviewDataDialog, TmyDataPreview);

    finalization

    ppUnRegisterForm(TmyDataPreview);


    end.



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



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2011
    Hi Nard,

    I've tried even using your simple example and I get the same result (nothing
    displays).
    Unfortunately I'm using a pretty old version (10.9) and its unlikely that
    I'll be able to upgrade at the moment
    so I'm attempting to debug and see what is happening.

    I can see that when the Preview button is clicked, it calls
    TdaCustomDataPreviw.Preview in the daDataView unit.
    This contains the following lines.

    lFormClass := PreviewFormClass;
    if (lFormClass = nil) or not
    lFormClass.InheritsFrom(TdaCustomPreviewDataDialog) then Exit;

    Tracing into PreviewFormClass shows the below is getting executed. The
    result is always false.
    Is it looking for the wrong class?

    { TdaADOQueryDataView.PreviewFormClass }
    class function TdaADOQueryDataView.PreviewFormClass: TFormClass;
    begin
    Result := TFormClass(GetClass('TdaPreviewDataDialog'));
    end; {class function, PreviewFormClass}

    Thanks for your assistance,

    Chris Hedges






  • edited February 2011
    I think I've figured out the fix but I'd like to confirm it with you first
    :)

    I changed the below method to be....

    class function TdaADOQueryDataView.PreviewFormClass: TFormClass;
    begin
    // Result := TFormClass(GetClass('TdaPreviewDataDialog'));
    Result := ppGetFormClass(TdaCustomPreviewDataDialog);
    end; {class function, PreviewFormClass}

    Does that seem correct? I now get my form displayed :)

    Thanks,

    Chris.



  • edited February 2011

    Glad you found a solution. In the future please specify the RB version you
    are using :)

    Going forward hope you will be upgrading to RB 12, which includes many
    powerful new features.

    Here is a link to What's New for RB 12. (Use the side menu to navigate to
    more detail and to see what was added for prior releases).

    http://www.digital-metaphors.com/rbWiki/General/What's_New/RB_12

    Also note that we have launched rbWiki, a great RB 'How To' resource that
    contains hundreds of tech tips and downloadable code examples.

    http://www.digital-metaphors.com/rbWiki


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



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.