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

Merge menu and dataview window

edited September 2002 in End User
Hi

I am currently getting together an end user solution using RB6.03 and ASTA
2.6 with Delphi 5 and MS SQL Server. I have now got the explorer and the
data dictionary working successfully. There are hundreds of tables in the
database and because of this I have added a grouping table which the data
dictionary SQL uses in a sub-query to retrieve only a small selection of
releated tables at any one time. This works very well however I need to add
a menu option to the dataview menu to allow the uer to select which data
model (and thus which portion of the data dictionary) they wish to look at.
I have looked at the merge menu functionality but this only seems to operate
on the design tabs menu. How can I add a menu item to the dataview tab menu
(without going back to RB source)? Also is it possible to open and close the
data dictionary datasets whilst inside RB so that it only retrieves the
subset the user wants?

Regards

Simon Callcott

Comments

  • edited September 2002
    We aren't sure what will happen when you switch it while the designer is
    open. It may work while the designer is open. It should work if you close
    the designer and reopen the designer with the new data dictionary datasets.
    When you change the data dictionary datasets, you should clear the global
    meta data cache as well. This cache is where RB stores info about the
    database so that it doesn't have to ask for the available table names and
    field names from the database directly, it is an optimization to increase
    performance in DADE. You can make this call:

    uses
    daMetaData;

    begin
    gMetaData.Clear;
    end;


    You still need to add a menu. This can be done. I'm emailing you a project
    that does this.

    unit CustomizeDesignerMenu;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
    Dialogs, StdCtrls, Menus, ComCtrls, ppEndUsr, ppComm, ppRelatv, ppProd,
    ppClass, ppReport,
    ppBands, ppCache, daIDE, daDBBDE;

    type

    TForm1 = class(TForm)
    ppReport1: TppReport;
    ppDesigner1: TppDesigner;
    btnDesign: TButton;
    ppHeaderBand1: TppHeaderBand;
    ppDetailBand1: TppDetailBand;
    ppFooterBand1: TppFooterBand;
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure btnDesignClick(Sender: TObject);
    procedure ppDesigner1TabChanged(Sender: TObject);

    private
    FDesignMenu: TMainMenu;
    FRAPMenu: TMainMenu;
    FDADEMenu: TMainMenu;

    procedure CustomizeDADEMenu(aMenu: TMainMenu);
    procedure CustomizeDesignMenu(aMenu: TMainMenu);
    procedure CustomizeRAPMenu(aMenu: TMainMenu);
    function DADEInstalled: Boolean;
    function DADETabCaption: String;
    function ExtractDADEMenu: TMainMenu;
    function ExtractRAPMenu: TMainMenu;
    function GetMainMenuFromTabSheet(aTabSheet: TTabSheet): TMainMenu;
    function GetTabSheetForCaption(const aCaption: String): TTabSheet;
    function RAPInstalled: Boolean;
    function RAPTabCaption: String;

    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    {$R *.dfm}

    uses
    ppUtils;

    procedure TForm1.CustomizeDesignMenu(aMenu: TMainMenu);
    begin
    aMenu.Items[0].Items[0].Enabled := False;
    end;

    procedure TForm1.CustomizeRAPMenu(aMenu: TMainMenu);
    begin
    aMenu.Items[0].Items[0].Enabled := False;
    end;

    procedure TForm1.CustomizeDADEMenu(aMenu: TMainMenu);
    begin
    aMenu.Items[0].Items[2].Enabled := False;
    end;

    procedure TForm1.FormCreate(Sender: TObject);
    begin

    FDesignMenu := ppDesigner1.Menu;
    FRAPMenu := nil;
    FDADEMenu := nil;

    CustomizeDesignMenu(FDesignMenu);

    end;

    procedure TForm1.btnDesignClick(Sender: TObject);
    begin
    ppDesigner1.ShowModal;
    end;

    function TForm1.ExtractDADEMenu: TMainMenu;
    var
    lTabSheet: TTabSheet;
    begin

    Result := nil;

    if DADEInstalled then
    begin
    lTabSheet := GetTabSheetForCaption(DADETabCaption);

    if (lTabSheet = nil) then
    raise Exception.Create('TForm1.ExtractDADEMenu: Unable to find
    TabSheet for DADE.');

    Result := GetMainMenuFromTabSheet(lTabSheet);
    end;

    end;

    function TForm1.ExtractRAPMenu: TMainMenu;
    var
    lTabSheet: TTabSheet;
    begin

    Result := nil;

    if RAPInstalled then
    begin
    lTabSheet := GetTabSheetForCaption(RAPTabCaption);

    if (lTabSheet = nil) then
    raise Exception.Create('TForm1.ExtractRAPMenu: Unable to find
    TabSheet for RAP.');

    Result := GetMainMenuFromTabSheet(lTabSheet);
    end;

    end;

    function TForm1.RAPInstalled: Boolean;
    begin
    Result := (GetClass('TraCodeModule') <> nil);
    end;

    function TForm1.DADEInstalled: Boolean;
    begin
    Result := (GetClass('TdaDataModule') <> nil);
    end;

    function TForm1.RAPTabCaption: String;
    begin
    Result := ppLoadStr(913); {'Calc'}
    end;

    function TForm1.DADETabCaption: String;
    begin
    Result := ppLoadStr(742); {Data}
    end;

    function TForm1.GetTabSheetForCaption(const aCaption: String): TTabSheet;
    var
    lPageControl: TPageControl;
    liIndex: Integer;
    lTabSheet: TTabSheet;
    begin

    liIndex := 0;
    Result := nil;

    lPageControl := ppDesigner1.Notebook;

    while (Result = nil) and (liIndex < lPageControl.PageCount) do
    begin
    lTabSheet := lPageControl.Pages[liIndex];

    if (CompareText(lTabSheet.Caption, aCaption) = 0) then
    Result := lTabSheet
    else
    Inc(liIndex);

    end;

    end;

    function TForm1.GetMainMenuFromTabSheet(aTabSheet: TTabSheet): TMainMenu;
    var
    liIndex: Integer;
    lComponent: TComponent;
    begin

    liIndex := 0;
    Result := nil;

    while (Result = nil) and (liIndex < aTabSheet.ComponentCount) do
    begin
    lComponent := aTabSheet.Components[liIndex];

    if (lComponent is TMainMenu) then
    Result := TMainMenu(lComponent)
    else
    Inc(liIndex);
    end;

    end;

    procedure TForm1.ppDesigner1TabChanged(Sender: TObject);
    begin

    if (RAPInstalled) and (ppDesigner1.Notebook.ActivePage.Caption =
    RAPTabCaption) then
    begin
    FRAPMenu := ExtractRAPMenu;

    CustomizeRAPMenu(FRAPMenu);
    end

    else if (DADEInstalled) and (ppDesigner1.Notebook.ActivePage.Caption =
    DADETabCaption) then
    begin
    FDADEMenu := ExtractDADEMenu;

    CustomizeDADEMenu(FDADEMenu);
    end;

    end;

    end.

    Cheers,

    Jim Bennett
    Digital Metaphors

  • edited September 2002
    Many Thanks for all your help.

    Best Regards

    Simon Callcott
This discussion has been closed.