141 lines
3.6 KiB
ObjectPascal
141 lines
3.6 KiB
ObjectPascal
unit uEWSampleInfo;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
|
|
Dialogs, StdCtrls, OleCtrls, SHDocVw, ExtCtrls, ToolsApi, Buttons;
|
|
|
|
type
|
|
TSampleInfoForm = class(TForm)
|
|
Panel1: TPanel;
|
|
wb_Browser: TWebBrowser;
|
|
cb_DontShow: TCheckBox;
|
|
sbPrint: TSpeedButton;
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
procedure sbPrintClick(Sender: TObject);
|
|
procedure cb_DontShowClick(Sender: TObject);
|
|
private
|
|
fIniFile: string;
|
|
public
|
|
class procedure RunSampleInfo(const aFilename:string);
|
|
end;
|
|
|
|
TProjectNotification = class(TInterfacedObject, IOTAIDENotifier)
|
|
public
|
|
procedure AfterCompile(Succeeded: Boolean);
|
|
procedure AfterSave;
|
|
procedure BeforeCompile(const Project: IOTAProject; var Cancel: Boolean);
|
|
procedure BeforeSave;
|
|
procedure Destroyed;
|
|
procedure FileNotification(NotifyCode: TOTAFileNotification; const FileName: String; var Cancel: Boolean);
|
|
procedure Modified;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
IniFiles;
|
|
|
|
{$R *.dfm}
|
|
|
|
{ TProjectNotification }
|
|
|
|
procedure TProjectNotification.AfterCompile(Succeeded: Boolean);
|
|
begin
|
|
end;
|
|
|
|
procedure TProjectNotification.AfterSave;
|
|
begin
|
|
end;
|
|
|
|
procedure TProjectNotification.BeforeCompile(const Project: IOTAProject; var Cancel: Boolean);
|
|
begin
|
|
end;
|
|
|
|
procedure TProjectNotification.BeforeSave;
|
|
begin
|
|
end;
|
|
|
|
procedure TProjectNotification.Destroyed;
|
|
begin
|
|
end;
|
|
|
|
procedure TProjectNotification.FileNotification(NotifyCode: TOTAFileNotification; const FileName: String; var Cancel: Boolean);
|
|
var
|
|
lFileExt: string;
|
|
begin
|
|
case NotifyCode of { }
|
|
ofnFileOpened:begin
|
|
lFileExt := ExtractFileExt(Filename);
|
|
if SameText(lFileExt,'.dpr') or SameText(lFileExt,'.dpk') or SameText(lFileExt,'.bpg') or SameText(lFileExt,'.bdsproj') or SameText(lFileExt,'.bdsgroup') or SameText(lFileExt,'.dproj') or SameText(lFileExt,'.groupproj') then begin
|
|
TSampleInfoForm.RunSampleInfo(Filename);
|
|
end;
|
|
end;
|
|
end; { case }
|
|
end;
|
|
|
|
procedure TProjectNotification.Modified;
|
|
begin
|
|
end;
|
|
|
|
{ TSampleInfoForm }
|
|
|
|
var
|
|
gLastForm: TSampleInfoForm;
|
|
|
|
class procedure TSampleInfoForm.RunSampleInfo(const aFilename: string);
|
|
var
|
|
lHelpFile,lIniFile: string;
|
|
begin
|
|
lHelpFile := ChangeFileExt(aFilename,'.sample.html');
|
|
lIniFile := ChangeFileExt(lHelpFile,'.ini');
|
|
if FileExists(lHelpFile) then begin
|
|
|
|
with TMemIniFile.Create(lIniFile) do try
|
|
if ReadBool('Options','DontShow',false) then exit;
|
|
finally
|
|
Free();
|
|
end;
|
|
|
|
FreeAndNil(gLastForm);
|
|
gLastForm := self.Create(Application);
|
|
with gLastForm do begin
|
|
Caption := 'Helpful tips about the '+ChangeFileExt(ExtractFileName(aFilename),'')+' project';
|
|
wb_Browser.Navigate(lHelpFile);
|
|
fIniFile := lIniFile;
|
|
Show();
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TSampleInfoForm.FormClose(Sender: TObject; var Action: TCloseAction);
|
|
begin
|
|
gLastForm := nil;
|
|
Release();
|
|
end;
|
|
|
|
var gNotify:integer;
|
|
|
|
procedure TSampleInfoForm.sbPrintClick(Sender: TObject);
|
|
var temp : OleVariant;
|
|
begin
|
|
wb_Browser.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER, temp, temp);
|
|
end;
|
|
|
|
procedure TSampleInfoForm.cb_DontShowClick(Sender: TObject);
|
|
begin
|
|
with TMemIniFile.Create(fIniFile) do try
|
|
WriteBool('Options','DontShow',cb_DontShow.Checked);
|
|
UpdateFile();
|
|
finally
|
|
Free();
|
|
end;
|
|
end;
|
|
|
|
initialization
|
|
gNotify := (BorlandIDEServices as IOTAServices).AddNotifier(TProjectNotification.Create());
|
|
finalization
|
|
(BorlandIDEServices as IOTAServices).RemoveNotifier(gNotify);
|
|
end.
|