Componentes.Terceros.jcl/official/1.104/experts/favfolders/IdeOpenDlgFavoriteUnit.pas
2009-02-27 12:18:04 +00:00

167 lines
6.0 KiB
ObjectPascal

{**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is IdeOpenDlgFavoriteUnit.pas. }
{ }
{ The Initial Developer of the Original Code is Petr Vones. }
{ Portions created by Petr Vones are Copyright (C) of Petr Vones. }
{ }
{**************************************************************************************************}
{ }
{ Last modified: $Date:: 2008-09-27 12:26:07 +0200 (sam., 27 sept. 2008) $ }
{ Revision: $Rev:: 2498 $ }
{ Author: $Author:: outchy $ }
{ }
{**************************************************************************************************}
unit IdeOpenDlgFavoriteUnit;
interface
{$I jcl.inc}
uses
SysUtils,
ToolsAPI, OpenDlgFavAdapter,
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
JclOtaUtils;
type
TJclOpenDialogsFavoriteExpert = class(TJclOTAExpert)
private
FFavOpenDialog: TFavOpenDialog;
procedure DialogClose(Sender: TObject);
procedure DialogShow(Sender: TObject);
public
constructor Create; reintroduce;
procedure RegisterCommands; override;
procedure UnregisterCommands; override;
end;
// design package entry point
procedure Register;
// expert DLL entry point
function JCLWizardInit(const BorlandIDEServices: IBorlandIDEServices;
RegisterProc: TWizardRegisterProc;
var TerminateProc: TWizardTerminateProc): Boolean; stdcall;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL: https://jcl.svn.sourceforge.net/svnroot/jcl/tags/JCL-1.104-Build3248/jcl/experts/favfolders/IdeOpenDlgFavoriteUnit.pas $';
Revision: '$Revision: 2498 $';
Date: '$Date: 2008-09-27 12:26:07 +0200 (sam., 27 sept. 2008) $';
LogPath: 'JCL\experts\favfolders'
);
{$ENDIF UNITVERSIONING}
implementation
uses
JclFileUtils, JclSysInfo,
JclOtaConsts, JclOtaResources;
procedure Register;
begin
try
RegisterPackageWizard(TJclOpenDialogsFavoriteExpert.Create);
except
on ExceptionObj: TObject do
begin
JclExpertShowExceptionDialog(ExceptionObj);
raise;
end;
end;
end;
var
JCLWizardIndex: Integer = -1;
procedure JclWizardTerminate;
begin
try
if JCLWizardIndex <> -1 then
TJclOTAExpertBase.GetOTAWizardServices.RemoveWizard(JCLWizardIndex);
except
on ExceptionObj: TObject do
begin
JclExpertShowExceptionDialog(ExceptionObj);
end;
end;
end;
function JCLWizardInit(const BorlandIDEServices: IBorlandIDEServices;
RegisterProc: TWizardRegisterProc;
var TerminateProc: TWizardTerminateProc): Boolean stdcall;
begin
try
TerminateProc := JclWizardTerminate;
JCLWizardIndex := TJclOTAExpertBase.GetOTAWizardServices.AddWizard(TJclOpenDialogsFavoriteExpert.Create);
Result := True;
except
on ExceptionObj: TObject do
begin
JclExpertShowExceptionDialog(ExceptionObj);
Result := False;
end;
end;
end;
constructor TJclOpenDialogsFavoriteExpert.Create;
begin
inherited Create(JclFavoritesExpertName);
end;
procedure TJclOpenDialogsFavoriteExpert.DialogClose(Sender: TObject);
begin
Settings.SaveStrings(JclFavoritesListSubKey, FFavOpenDialog.FavoriteFolders);
Settings.SaveString(PictDialogFolderItemName, FFavOpenDialog.PictureDialogLastFolder);
end;
procedure TJclOpenDialogsFavoriteExpert.DialogShow(Sender: TObject);
begin
Settings.LoadStrings(JclFavoritesListSubKey, FFavOpenDialog.FavoriteFolders);
end;
procedure TJclOpenDialogsFavoriteExpert.RegisterCommands;
begin
inherited RegisterCommands;
FFavOpenDialog := InitializeFavOpenDialog;
FFavOpenDialog.DisableHelpButton := True;
FFavOpenDialog.HookDialogs;
FFavOpenDialog.OnClose := DialogClose;
FFavOpenDialog.OnShow := DialogShow;
FFavOpenDialog.PictureDialogLastFolder := Settings.LoadString(PictDialogFolderItemName,
PathAddSeparator(GetCommonFilesFolder) + BorlandImagesPath);
end;
procedure TJclOpenDialogsFavoriteExpert.UnregisterCommands;
begin
FFavOpenDialog.UnhookDialogs;
inherited UnregisterCommands;
end;
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.