Object Repository Wizard Unit


  In order to add a new Wizard to the object repository you must implement an object that supports IOTAFormWizard or IOTAProjectWizard. To simplify this the OTA defines TNotifierObject that supports the basic methods for IOTAWizard. If we derive from this class we can concentrate on the methods needed for the repository.

    Notice here you must explicitly define the interfaces IOTAWizard, IOTARepositoryWizard, and IOTAProjectWizard (or IOTAFormWizard)

  TSampleWizard = class(TNotifierObject, IOTAWizard, IOTARepositoryWizard, IOTAProjectWizard)

to ensure that they are all defined when the IDE queries for each interface.

 

IOTARepositoryWizard = interface(IOTAWizard)
  ['{B75C0CE1-EEA6-11D1-9504-00608CCBF153}']
  function GetAuthor: string;
  function GetComment: string;
  function GetPage: string;
  function GetGlyph: Cardinal;
  end;

IOTAFormWizard = interface(IOTARepositoryWizard)
  ['{36C8BF35-EFFE-11D1-AB1D-00C04FB16FB3}']
end;

IOTAProjectWizard = interface(IOTARepositoryWizard)
  ['{36C8BF36-EFFE-11D1-AB1D-00C04FB16FB3}']
end;

The Wizard to add a Menu Item to Delphi implment an object that supports IOTAMenuWizard.

IOTAMenuWizard = interface(IOTAWizard)
  ['{B75C0CE2-EEA6-11D1-9504-00608CCBF153}']
  function GetMenuText: string;
  end;

 

  Every Respository Wizard will start from as unit similar to the following.

unit Wizard;

interface
{$I Compilers.inc} // Compiler Defines
{$R OTAWizardsEx.res} // Wizard Icons
uses SysUtils, Windows, Controls, ToolsApi;
type
  TSampleWizard = class(TNotifierObject, IOTAWizard, IOTARepositoryWizard, IOTAProjectWizard)
  // IOTAWizard
  function GetIDString: string;
  function GetName: string;
  function GetState: TWizardState;
  procedure Execute;
  // IOTARepositoryWizard
  function GetAuthor: string;
  function GetComment: string;
  function GetPage: string;
  function GetGlyph: {$IFDEF COMPILER_6_UP}Cardinal{$ELSE}HICON{$ENDIF};
end;

implementation

{ TSampleWizard }

  procedure TSampleWizard.Execute;
  begin
  MessageBox(0, 'Executed Wizard', 'Hi', MB_OK);
  end;

  function TSampleWizard.GetAuthor: string;
  begin
  //
  // When Object Repository is in Detail mode used in the Author column
  //
  Result := 'MustangPeak'
  end;

  function TSampleWizard.GetComment: string;
  begin
  //
  // When Object Repository is in Detail mode used in the Comment column
  //
  Result := 'Sample Repository Wizard'
  end;

  function TSampleWizard.GetGlyph: {$IFDEF COMPILER_6_UP}Cardinal{$ELSE}HICON{$ENDIF};
  begin
  // Note here the Image in the resource file MUST contain a 32x32 icon AND a 16x16 icon in the
  // same icon resource.
  Result := LoadIcon(hInstance, 'SAMPLEWIZARD');
  end;

  function TSampleWizard.GetIDString: string;
  begin
  //
  // Unique name for the Wizard used internally by Delphi
  //
  Result := 'MustangPeak.SampleWizard';
  end;

  function TSampleWizard.GetName: string;
  begin
  //
  // Name used for user messages and in the Object Repository if
  // implementing a IOTARepositoryWizard object
  //
  Result := 'MustangPeak Sample Wizard';
  end;

  function TSampleWizard.GetPage: string;
  begin
  //
  // Page in the Repository to add the Wizard. This may be a Delphi
  // defined page or a unique name to create a new page.
  // If an empty string is returned the wizard is installed into a page named "Wizards"
  //
  Result := 'MustangPeak'
  end;

  function TSampleWizard.GetState: TWizardState;
  begin
  //
  // For Menu Item Wizards only
  //
  Result := [];
  end;
end.

 

  The next step is the registration of the Wizard with Delphi.

 


mustangpeak.net

  Last Modified on: