home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / Runimage / Delphi50 / Demos / ToolsAPI / ActionServices / wizmain.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  2.0 KB  |  102 lines

  1. unit WizMain;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, ToolsApi;
  7.  
  8. type
  9.   EActionServices = class(Exception);
  10.  
  11.   TActionServices = class(TNotifierObject, IOTAWizard, IOTAMenuWizard)
  12.   private
  13.     FIndex: Integer;
  14.     procedure SetIndex(const Value: Integer);
  15.   public
  16.     function GetIDString: string;
  17.     function GetName: string;
  18.     function GetState: TWizardState;
  19.     procedure Execute;
  20.     function GetMenuText: string;
  21.     property Index: Integer read FIndex write SetIndex;
  22.   end;
  23.  
  24. implementation
  25.  
  26. uses
  27.   FrmMain;
  28.  
  29. var
  30.   ActionServices: TActionServices;
  31.  
  32. resourcestring
  33.   sActionError = 'Error creating ActionServices wizard';
  34.  
  35. { TActionServices }
  36.  
  37. procedure TActionServices.Execute;
  38. begin
  39.   if Form2 = nil then
  40.     Form2 := TForm2.Create(nil);
  41.  
  42.   Form2.Show;
  43. end;
  44.  
  45. function TActionServices.GetIDString: string;
  46. begin
  47.   Result := 'Borland.ActionServices.Demo.1'; { do not localize }
  48. end;
  49.  
  50. function TActionServices.GetMenuText: string;
  51. resourcestring
  52.   sMenuText = 'Test Action Services';
  53.  
  54. begin
  55.   Result := sMenuText;
  56. end;
  57.  
  58. function TActionServices.GetName: string;
  59. begin
  60.   Result := 'Borland.ActionServices.Demo'; { do not localize }
  61. end;
  62.  
  63. function TActionServices.GetState: TWizardState;
  64. begin
  65.   Result := [wsEnabled];
  66. end;
  67.  
  68. procedure InitActionServices;
  69. begin
  70.   if (BorlandIDEServices <> nil) then
  71.   begin
  72.     ActionServices := TActionServices.Create;
  73.     ActionServices.Index := (BorlandIDEServices as IOTAWizardServices).AddWizard(ActionServices as IOTAWizard);
  74.     if ActionServices.Index < 0 then
  75.       raise EActionServices.Create(sActionError);
  76.   end;
  77. end;
  78.  
  79. procedure DoneActionServices;
  80. begin
  81.   if (BorlandIDEServices <> nil) then
  82.   begin
  83.     if Form2 <> nil then
  84.       Form2.Free;
  85.  
  86.     (BorlandIDEServices as IOTAWizardServices).RemoveWizard(ActionServices.Index);
  87.   end;
  88. end;
  89.  
  90. procedure TActionServices.SetIndex(const Value: Integer);
  91. begin
  92.   FIndex := Value;
  93. end;
  94.  
  95. initialization
  96.   InitActionServices;
  97.  
  98. finalization
  99.   DoneActionServices;
  100.  
  101. end.
  102.