Feel free to use this class in any of your Delphi or C++Builder plugins. It really will save you some time.
unit IdeHelpers;
interface
uses
ToolsAPI;
type
TWizardList = class
private
FWizardService: IOTAWizardServices;
FItems: array of Integer;
public
constructor Create;
destructor Destroy; override;
function Add(const Wizard: IOTAWizard): Integer;
procedure Remove(Value: Integer);
end;
implementation
{ TWizardList }
constructor TWizardList.Create;
begin
FWizardService := nil;
end;
function TWizardList.Add(const Wizard: IOTAWizard): Integer;
var
Index: Integer;
begin
if FWizardService = nil then
FWizardService := BorlandIDEServices as IOTAWizardServices;
Result := FWizardService.AddWizard(Wizard);
Index := Length(FItems);
SetLength(FItems, Index + 1);
FItems[Index] := Result;
end;
procedure TWizardList.Remove(Value: Integer);
var
Index: Integer;
begin
if FWizardService = nil then
FWizardService := BorlandIDEServices as IOTAWizardServices;
FWizardService.RemoveWizard(Value);
for Index := 0 to Length(FItems) - 1 do
begin
if FItems[Index] = Value then
begin
FItems[Index] := -1;
end;
end;
end;
destructor TWizardList.Destroy;
var
Index: Integer;
begin
if FWizardService <> nil then
begin
for Index := 0 to Length(FItems) - 1 do
begin
if FItems[Index] <> -1 then
FWizardService.RemoveWizard(FItems[Index]);
end;
end;
inherited;
end;
end.
No comments:
Post a Comment