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

ppToolbarTBX SavePreferences

edited March 2008 in General
I have a simple report in my application but when my application
runs, it complains that it is unable to write the 'RBuilder.ini'. In
my debug log, it looks like the .ini needs to be written by the
ppToolbarTBX unit. How do I initialize this in my application
so I won't get this error? I am using the built-in preview for
the report.

Thanks in advance.

Andy

Comments

  • edited March 2008

    ----------------------------------------------------
    Tech Tip: RBuilder Ini Storage
    ----------------------------------------------------

    For an end-user reporting application, use the TppDesigner IniStorageType
    and
    InitStorageName properties can to control how/where ReportBuilder stores
    user
    preferences.

    For a reporting application that does not include the TppDesigner component,
    the
    settings can be configured programmatically.


    1. To modify the location of RBuilder.ini

    uses
    ppIniStorage,
    ppFileUtils;

    procedure TForm1.FormCreate(Sender: TObject);
    var
    lsStorageName: String;
    begin

    lsStorageName := TppFileUtils.GetApplicationFilePath + '\RBuilder.ini';

    TppIniStoragePlugIn.SetStorageName(lsStorageName);

    end;


    2. To modify the storage to use the Windows Registry

    uses
    ppIniStorage;

    begin

    // configure the ini storage to use the registry
    ConfigureIniStorage(TppRegistry.ClassDescription,
    TppRegistry.DefaultStorageName);

    end;


    procedure ConfigureIniStorage(aStorageType, aStorageName: String);
    var
    lIniStorageClass: TppIniStorageClass;
    begin

    lIniStorageClass := TppIniStoragePlugIns.GetClassForName(aStorageType);

    if (lIniStorageClass <> nil) then
    begin
    TppIniStoragePlugIn.SetClass(lIniStorageClass);
    TppIniStoragePlugIn.SetStorageName(aStorageName);
    end;

    end;


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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2008
    I forgot to mention that I am running this on Vista. I had to elevate
    the permission to Administrator in order for the application to run,
    but it would be better if I could set the .ini file to a user path. I think
    this has something to do with the report designer. Please advice and
    thank you in advance.

    Andy

  • edited March 2008
    Hi Nard,

    Thanks for the speedy response.

    Andy

  • edited March 2008
    Hi Nard,

    It is still giving me the same error. I tried putting the code in the
    FormCreate
    as well as in the .dpr but still complains that it is trying to write to the
    Windows
    folder. Any idea why?

    Thanks in advance.

    Andy

  • edited March 2008
    Hi Nard,

    Maybe I need to put it in the initalization section? How would I do this?
    It seems to bomb before the FormCreate event fires.

    Thanks again.

    Andy

  • edited March 2008

    What version of RB are you using? Check the Help | About box of the report
    designer.

    If you are not using RB 10.07, then try updating. I think we modified the
    timing of when RBuilder.ini is first accessed, I do not recall in which
    version we did.


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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2008
    Hi Nard,

    I am using version 10.02.

    Andy

This discussion has been closed.