{**************************************************************************************************} { } { 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. } { } {**************************************************************************************************} { } { Unit owner: Petr Vones } { Last modified: $Date: 2006-05-30 00:02:45 +0200 (mar., 30 mai 2006) $ } { } {**************************************************************************************************} unit IdeOpenDlgFavoriteUnit; interface {$I jcl.inc} uses SysUtils, ToolsAPI, OpenDlgFavAdapter, 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; 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; var OTAWizardServices: IOTAWizardServices; begin try if JCLWizardIndex <> -1 then begin Supports(BorlandIDEServices, IOTAWizardServices, OTAWizardServices); if not Assigned(OTAWizardServices) then raise EJclExpertException.CreateTrace(RsENoWizardServices); OTAWizardServices.RemoveWizard(JCLWizardIndex); end; except on ExceptionObj: TObject do begin JclExpertShowExceptionDialog(ExceptionObj); end; end; end; function JCLWizardInit(const BorlandIDEServices: IBorlandIDEServices; RegisterProc: TWizardRegisterProc; var TerminateProc: TWizardTerminateProc): Boolean stdcall; var OTAWizardServices: IOTAWizardServices; begin try TerminateProc := JclWizardTerminate; Supports(BorlandIDEServices, IOTAWizardServices, OTAWizardServices); if not Assigned(OTAWizardServices) then raise EJclExpertException.CreateTrace(RsENoWizardServices); JCLWizardIndex := OTAWizardServices.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; end.