unit SimpleNotifierUnit;
interface
procedure Register;
implementation
uses
SysUtils, ToolsAPI, DCCStrs;
type
TSimpleNotifier =
class(TNotifierObject, IOTAIDENotifier)
public
procedure AfterCompile(Succeeded: Boolean);
procedure BeforeCompile(
const Project: IOTAProject;
var Cancel: Boolean);
procedure FileNotification(NotifyCode: TOTAFileNotification;
const FileName:
string;
var Cancel: Boolean);
end;
var
NotifierIndex: Integer = -1;
procedure Register;
begin
NotifierIndex := (BorlandIDEServices
as IOTAServices).AddNotifier(TSimpleNotifier.Create);
end;
{ TSimpleNotifier }
procedure TSimpleNotifier.AfterCompile(Succeeded: Boolean);
begin
//
end;
procedure TSimpleNotifier.BeforeCompile(
const Project: IOTAProject;
var Cancel: Boolean);
begin
//
end;
procedure TSimpleNotifier.FileNotification(NotifyCode: TOTAFileNotification;
const FileName:
string;
var Cancel: Boolean);
var
ProjModule: IOTAModule;
Project: IOTAProject;
BuildConfigs: IOTAProjectOptionsConfigurations;
EnvOptions: IOTAEnvironmentOptions;
Config: IOTABuildConfiguration;
SearchPath, SearchPathConfig, SearchPathLib:
string;
begin
if (NotifyCode = ofnFileOpened)
and
{$IF COMPILERVERSION >= 22.0}
(BorlandIDEServices
as IOTAServices).IsProject(FileName)
{$ELSE}
SameText('
.dproj', ExtractFileExt(FileName))
{$IFEND}
then
begin
ProjModule := (BorlandIDEServices
as IOTAModuleServices).FindModule(FileName);
if Supports(ProjModule, IOTAProject, Project)
and
Supports(Project.ProjectOptions, IOTAProjectOptionsConfigurations, BuildConfigs)
then
begin
Config := BuildConfigs.BaseConfiguration;
(BorlandIDEServices
as IOTAMessageServices).AddTitleMessage(Format('
Opened Project %s', [FileName]));
SearchPathConfig := Config.Value[sUnitSearchPath];
(BorlandIDEServices
as IOTAMessageServices).AddTitleMessage(Format('
Base.SearchPath = %s', [SearchPathConfig]));
EnvOptions := (BorlandIDEServices
as IOTAServices).GetEnvironmentOptions;
SearchPathLib := EnvOptions.Values['
LibraryPath'];
(BorlandIDEServices
as IOTAMessageServices).AddTitleMessage(Format('
EnvironmentOptions.LibraryPath = %s', [SearchPathLib]));
SearchPath := SearchPathConfig;
if SearchPathLib <> '
'
then
begin
if SearchPath <> '
'
then
SearchPath := SearchPath + '
;';
SearchPath := SearchPath + SearchPathLib;
end;
(BorlandIDEServices
as IOTAMessageServices).AddTitleMessage(Format('
SearchPath = %s', [SearchPath]));
end;
end;
end;
initialization
finalization
if NotifierIndex <> -1
then
(BorlandIDEServices
as IOTAServices).RemoveNotifier(NotifierIndex);
end.