Enable 'Add Existing' menu on default Auto Forms

The 'Add Existing' menu in the default autoforms was not implimented and is always disabled. This simple form patches the bold source to enable this option.

While building an application it is useful to use the default auto forms, but it is frustrating that the 'Add Existing' menu option was never implimented. To enable this functionality, follow the instructions below.



Place the two files contained in this archive(SelectDlg.zip) into the Bold source directory (by default, C:\Program Files\BoldSoft\BfDR40D7Arch\Source ) and be sure that the source directory is in the Delphi library path (Tools, Environment Options, Library, Library Path).



To enable the form it is also necessary to patch the Bold file BoldAFPDefault.pas to include the following:





  • Add "formGenericSelect" to the implementation uses clause (line 238)



  • Add this method declaration to the TRolebutton class (about line 193):



      TRoleButton = class(TButton)

      public

        [...]

       procedure AddExistingObject( Sender: TObject );


      end;





  • In method TRoleMenu.Create, add the indicated lines below (line 1288):



      anItem := TMenuItem.Create(Self);

      anItem.Caption := 'Add existing...';

      anItem.Enabled := False;

    { start additions by david knaack }

       anItem.Enabled := True;

       anItem.OnClick := fRoleButton.AddExistingObject;

    { stop additions }






  • Add this method to the implementation section (line 1184):



    {-----------------------------------------------------------------------------

      Procedure: TRoleButton.AddExistingObject

      Date: 12-Feb-2003

      Descrip: Added by David Knaack

    -----------------------------------------------------------------------------}

    procedure TRoleButton.AddExistingObject( Sender: TObject );

    var

      ObjectReference: TBoldObjectReference;

      dlgSelect : TfrmGenericSelect;

    begin

      if Assigned(BoldHandle) then

      begin

        ObjectReference := BoldHandle.Value as TBoldObjectReference;



        dlgSelect := TfrmGenericSelect.Create( self, ObjectReference.BoldSystem, BoldHandle.BoldType.ExpressionName );

        try

           if dlgSelect.ShowModal <> mrOK then Exit;



           ObjectReference.BoldObject := dlgSelect.SelectedBoldObject;

        finally

           dlgSelect.Free;

        end;

      end;

    end;







Now the 'Add Existing' menu should be available for members that are bold objects.

 

Share this article!

Follow us!

Find more helpful articles: