{**************************************************************************************************} { } { 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:: 2009-10-16 19:11:39 +0200 (ven., 16 oct. 2009) $ } { Revision: $Rev:: 3044 $ } { Author: $Author:: outchy $ } { } {**************************************************************************************************} unit IdeOpenDlgFavoriteUnit; interface {$I jcl.inc} uses SysUtils, ToolsAPI, JclOpenDialogFavorites, {$IFDEF UNITVERSIONING} JclUnitVersioning, {$ENDIF UNITVERSIONING} JclOtaUtils; type TJclOpenDialogsFavoriteExpert = class(TJclOTAExpert) private FOpenDialog: TJclOpenDialogFavoritesHook; 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-2.1-Build3536/jcl/experts/favfolders/IdeOpenDlgFavoriteUnit.pas $'; Revision: '$Revision: 3044 $'; Date: '$Date: 2009-10-16 19:11:39 +0200 (ven., 16 oct. 2009) $'; LogPath: 'JCL\experts\favfolders'; Extra: ''; Data: nil ); {$ENDIF UNITVERSIONING} implementation uses JclFileUtils, JclSysInfo, JclOtaConsts, JclOtaResources; procedure Register; begin try RegisterPackageWizard(TJclOpenDialogsFavoriteExpert.Create); except on ExceptionObj: TObject do begin JclExpertShowExceptionDialog(ExceptionObj); 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, FOpenDialog.FavoriteFolders); Settings.SaveString(PictDialogFolderItemName, FOpenDialog.PictureDialogLastFolder); end; procedure TJclOpenDialogsFavoriteExpert.DialogShow(Sender: TObject); begin Settings.LoadStrings(JclFavoritesListSubKey, FOpenDialog.FavoriteFolders); end; procedure TJclOpenDialogsFavoriteExpert.RegisterCommands; begin inherited RegisterCommands; FOpenDialog := InitializeOpenDialogFavorites; FOpenDialog.DisableHelpButton := True; FOpenDialog.HookDialogs; FOpenDialog.OnClose := DialogClose; FOpenDialog.OnShow := DialogShow; FOpenDialog.PictureDialogLastFolder := Settings.LoadString(PictDialogFolderItemName, PathAddSeparator(GetCommonFilesFolder) + BorlandImagesPath); end; procedure TJclOpenDialogsFavoriteExpert.UnregisterCommands; begin FOpenDialog.UnhookDialogs; FinalizeOpenDialogFavorites; inherited UnregisterCommands; end; {$IFDEF UNITVERSIONING} initialization RegisterUnitVersion(HInstance, UnitVersioning); finalization UnregisterUnitVersion(HInstance); {$ENDIF UNITVERSIONING} end.