/jcl/source/vcl/JclOpenDialogFavorites.pas

https://github.com/the-Arioch/jcl · Pascal · 575 lines · 440 code · 53 blank · 82 comment · 31 complexity · 3a65015a381533f3d963377ed634679b MD5 · raw file

  1. {**************************************************************************************************}
  2. { }
  3. { Project JEDI Code Library (JCL) }
  4. { }
  5. { The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
  6. { you may not use this file except in compliance with the License. You may obtain a copy of the }
  7. { License at http://www.mozilla.org/MPL/ }
  8. { }
  9. { Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
  10. { ANY KIND, either express or implied. See the License for the specific language governing rights }
  11. { and limitations under the License. }
  12. { }
  13. { The Original Code is OpenDlgFavAdapter.pas. }
  14. { }
  15. { The Initial Developer of the Original Code is Petr Vones. }
  16. { Portions created by Petr Vones are Copyright (C) Petr Vones. All rights reserved. }
  17. { }
  18. { Contributor(s): }
  19. { Salvatore Besso }
  20. { Florent Ouchet (move to JCL runtime) }
  21. { }
  22. {**************************************************************************************************}
  23. { }
  24. { Last modified: $Date:: $ }
  25. { Revision: $Rev:: $ }
  26. { Author: $Author:: $ }
  27. { }
  28. {**************************************************************************************************}
  29. unit JclOpenDialogFavorites;
  30. interface
  31. {$I jcl.inc}
  32. uses
  33. {$IFDEF HAS_UNITSCOPE}
  34. Winapi.Windows, Winapi.Messages, Winapi.ShlObj, System.Classes, System.SysUtils, Vcl.Controls, Vcl.StdCtrls, Vcl.ExtCtrls,
  35. {$ELSE ~HAS_UNITSCOPE}
  36. Windows, Messages, ShlObj, Classes, SysUtils, Controls, StdCtrls, ExtCtrls,
  37. {$ENDIF ~HAS_UNITSCOPE}
  38. {$IFDEF UNITVERSIONING}
  39. JclUnitVersioning,
  40. {$ENDIF UNITVERSIONING}
  41. JclPeImage, JclWin32,
  42. JclOpenDialogHooks;
  43. // old-style open dialogs are supported by all versions of Delphi
  44. {$DEFINE OLDSTYLE}
  45. // new-style file dialogs are supported by Delphi 2007 and newer
  46. // it is disabled in D2007, because the D2006 RTL does not support it at all
  47. {$IFDEF RTL200_UP}
  48. {$DEFINE NEWSTYLE}
  49. {$ENDIF RTL200_UP}
  50. type
  51. {$NODEFINE TJclOpenDialogFavoritesHook} // IFileDialogCustomize is badly emitted
  52. TJclOpenDialogFavoritesHook = class (TJclOpenDialogHook{$IFDEF NEWSTYLE}, IFileDialogControlEvents, IFileDialogEvents, IInterface{$ENDIF})
  53. private
  54. FFavoriteFolders: TStrings;
  55. FTextAdd: string;
  56. FTextDelete: string;
  57. FTextVirtual: string;
  58. {$IFDEF OLDSTYLE}
  59. private
  60. FFavoriteComboBox: TComboBox;
  61. FFavoriteStaticText: TStaticText;
  62. FFavoritePanel: TPanel;
  63. procedure FavoriteComboBoxClick(Sender: TObject);
  64. protected
  65. procedure DialogAdjustControlPos; override;
  66. procedure DialogFolderChange; override;
  67. procedure DialogShow; override;
  68. procedure DialogClose; override;
  69. {$ENDIF OLDSTYLE}
  70. {$IFDEF NEWSTYLE}
  71. private
  72. FComboboxCount: Integer;
  73. FComboboxListItem,
  74. FComboboxAddItem,
  75. FComboboxDeleteItem,
  76. FComboboxVirtualItem: Boolean;
  77. FTextList: string;
  78. procedure FileDialogCleanCombobox(const AFileDialogCustomize: IFileDialogCustomize);
  79. procedure FileDialogFillCombobox(const AFileDialogCustomize: IFileDialogCustomize; ListItem, AddItem, DeleteItem, VirtualItem: Boolean);
  80. protected
  81. procedure FileDialogCreate(const AFileDialog: IFileDialog); override;
  82. public
  83. { IInterface }
  84. function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
  85. function _AddRef: Integer; stdcall;
  86. function _Release: Integer; stdcall;
  87. public
  88. { IFileDialogEvents }
  89. function OnFileOk(const pfd: IFileDialog): HResult; stdcall;
  90. function OnFolderChanging(const pfd: IFileDialog;
  91. const psiFolder: IShellItem): HResult; stdcall;
  92. function OnFolderChange(const pfd: IFileDialog): HResult; stdcall;
  93. function OnSelectionChange(const pfd: IFileDialog): HResult; stdcall;
  94. function OnShareViolation(const pfd: IFileDialog; const psi: IShellItem;
  95. out pResponse: DWORD): HResult; stdcall;
  96. function OnTypeChange(const pfd: IFileDialog): HResult; stdcall;
  97. function OnOverwrite(const pfd: IFileDialog; const psi: IShellItem;
  98. out pResponse: DWORD): HResult; stdcall;
  99. public
  100. { IFileDialogControlEvents }
  101. function OnItemSelected(const pfdc: IFileDialogCustomize; dwIDCtl: DWORD;
  102. dwIDItem: DWORD): HResult; stdcall;
  103. function OnButtonClicked(const pfdc: IFileDialogCustomize;
  104. dwIDCtl: DWORD): HResult; stdcall;
  105. function OnCheckButtonToggled(const pfdc: IFileDialogCustomize;
  106. dwIDCtl: DWORD; bChecked: BOOL): HResult; stdcall;
  107. function OnControlActivating(const pfdc: IFileDialogCustomize;
  108. dwIDCtl: DWORD): HResult; stdcall;
  109. {$ENDIF NEWSTYLE}
  110. public
  111. constructor Create; override;
  112. destructor Destroy; override;
  113. procedure LoadFavorites(const FileName: string);
  114. property FavoriteFolders: TStrings read FFavoriteFolders;
  115. end;
  116. {$NODEFINE InitializeOpenDialogFavorites}
  117. function InitializeOpenDialogFavorites: TJclOpenDialogFavoritesHook;
  118. {$NODEFINE FinalizeOpenDialogFavorites}
  119. procedure FinalizeOpenDialogFavorites;
  120. {$IFDEF UNITVERSIONING}
  121. const
  122. UnitVersioning: TUnitVersionInfo = (
  123. RCSfile: '$URL$';
  124. Revision: '$Revision$';
  125. Date: '$Date$';
  126. LogPath: 'JCL\source\vcl';
  127. Extra: '';
  128. Data: nil
  129. );
  130. {$ENDIF UNITVERSIONING}
  131. implementation
  132. uses
  133. {$IFDEF HAS_UNITSCOPE}
  134. Winapi.CommDlg, Winapi.Dlgs,
  135. {$ELSE ~HAS_UNITSCOPE}
  136. CommDlg, Dlgs,
  137. {$ENDIF ~HAS_UNITSCOPE}
  138. JclBase, JclFileUtils, JclStrings, JclSysInfo, JclSysUtils, JclVclResources;
  139. {$IFDEF NEWSTYLE}
  140. const
  141. CTRLID_COMBOBOX = $2346;
  142. ITEMID_LIST = $FFFF;
  143. ITEMID_ADD = $FFFE;
  144. ITEMID_DELETE = $FFFD;
  145. ITEMID_VIRTUAL = $FFFC;
  146. {$ENDIF NEWSTYLE}
  147. function InitializeOpenDialogFavorites: TJclOpenDialogFavoritesHook;
  148. begin
  149. Result := InitializeOpenDialogHook(TJclOpenDialogFavoritesHook) as TJclOpenDialogFavoritesHook;
  150. end;
  151. procedure FinalizeOpenDialogFavorites;
  152. begin
  153. FinalizeOpenDialogHook;
  154. end;
  155. //=== { TJclOpenDialogFavoritesHook } ========================================
  156. constructor TJclOpenDialogFavoritesHook.Create;
  157. begin
  158. inherited Create;
  159. FFavoriteFolders := TStringList.Create;
  160. {$IFDEF OLDSTYLE}
  161. FFavoritePanel := TPanel.Create(nil);
  162. FFavoritePanel.Name := 'FavoritePanel';
  163. FFavoritePanel.BevelOuter := bvNone;
  164. FFavoritePanel.Caption := '';
  165. FFavoritePanel.FullRepaint := False;
  166. FFavoriteComboBox := TComboBox.Create(nil);
  167. FFavoriteComboBox.Parent := FFavoritePanel;
  168. FFavoriteComboBox.Align := alClient;
  169. FFavoriteComboBox.Style := csDropDownList;
  170. FFavoriteComboBox.Sorted := True;
  171. FFavoriteComboBox.OnClick := FavoriteComboBoxClick;
  172. FFavoriteStaticText := TStaticText.Create(nil);
  173. FFavoriteStaticText.SetBounds(6, 18, FFavoriteStaticText.Width, FFavoriteStaticText.Height);
  174. FFavoriteStaticText.Caption := LoadResString(@RsOpenDialogFavorites);
  175. FFavoriteStaticText.AutoSize := True;
  176. FFavoriteStaticText.FocusControl := FFavoriteComboBox;
  177. {$ENDIF OLDSTYLE}
  178. FTextAdd := LoadResString(@RsOpenDialogAdd);
  179. FTextDelete := LoadResString(@RsOpenDialogDelete);
  180. FTextVirtual := LoadResString(@RsOpenDialogVirtual);
  181. {$IFDEF NEWSTYLE}
  182. FTextList := LoadResString(@RsOpenDialogList);
  183. {$ENDIF NEWSTYLE}
  184. end;
  185. destructor TJclOpenDialogFavoritesHook.Destroy;
  186. begin
  187. {$IFDEF OLDSTYLE}
  188. FreeAndNil(FFavoriteComboBox);
  189. FreeAndNil(FFavoritePanel);
  190. FreeAndNil(FFavoriteStaticText);
  191. {$ENDIF OLDSTYLE}
  192. FreeAndNil(FFavoriteFolders);
  193. inherited Destroy;
  194. end;
  195. {$IFDEF OLDSTYLE}
  196. procedure TJclOpenDialogFavoritesHook.DialogAdjustControlPos;
  197. var
  198. FileTypeStaticTextRect, FileTypeEditRect, // ID = 1136 1089
  199. FileNameStaticTextRect, FileNameEditRect: TRect; // ID = 1148 1090
  200. procedure GetDlgItemRect(ItemID: Integer; var R: TRect);
  201. begin
  202. GetWindowRect(GetDlgItem(FParentWnd, ItemID), R);
  203. MapWindowPoints(0, FParentWnd, R, 2);
  204. end;
  205. begin
  206. inherited DialogAdjustControlPos;
  207. GetDlgItemRect(stc2, FileTypeStaticTextRect);
  208. GetDlgItemRect(cmb1, FileTypeEditRect);
  209. GetDlgItemRect(stc3, FileNameStaticTextRect);
  210. GetDlgItemRect(cmb13, FileNameEditRect);
  211. FFavoriteStaticText.Left := FileTypeStaticTextRect.Left;
  212. FFavoriteStaticText.Top := 2 * FileTypeStaticTextRect.Top - FileNameStaticTextRect.Top;
  213. FFavoritePanel.Left := FileNameEditRect.Left;
  214. FFavoritePanel.Top := 2 * FileTypeEditRect.Top - FileNameEditRect.Top;
  215. FFavoritePanel.Width := FileTypeEditRect.Right - FileTypeEditRect.Left;
  216. end;
  217. procedure TJclOpenDialogFavoritesHook.DialogClose;
  218. begin
  219. inherited DialogClose;
  220. if not IsOpenPictureDialog then
  221. begin
  222. FFavoriteComboBox.Items.Delete(0);
  223. FavoriteFolders.Assign(FFavoriteComboBox.Items);
  224. end;
  225. FFavoritePanel.ParentWindow := 0;
  226. FFavoriteStaticText.ParentWindow := 0;
  227. FParentWnd := 0;
  228. end;
  229. procedure TJclOpenDialogFavoritesHook.DialogFolderChange;
  230. var
  231. Path: string;
  232. begin
  233. inherited DialogFolderChange;
  234. Path := CurrentFolder;
  235. FFavoriteComboBox.ItemIndex := FFavoriteComboBox.Items.IndexOf(Path);
  236. if FFavoriteComboBox.ItemIndex = -1 then
  237. begin
  238. if Path <> '' then
  239. FFavoriteComboBox.Items[0] := FTextAdd
  240. else
  241. FFavoriteComboBox.Items[0] := FTextVirtual;
  242. FFavoriteComboBox.ItemIndex := 0;
  243. end
  244. else
  245. FFavoriteComboBox.Items[0] := FTextDelete;
  246. FFavoriteComboBox.Invalidate;
  247. end;
  248. procedure TJclOpenDialogFavoritesHook.DialogShow;
  249. begin
  250. inherited DialogShow;
  251. if not IsOpenPictureDialog then
  252. begin
  253. FFavoritePanel.ParentWindow := FHandle;
  254. FFavoriteStaticText.ParentWindow := FHandle;
  255. FFavoriteComboBox.Items.Assign(FavoriteFolders);
  256. FFavoriteComboBox.Items.Insert(0, FTextAdd);
  257. end;
  258. end;
  259. procedure TJclOpenDialogFavoritesHook.FavoriteComboBoxClick(Sender: TObject);
  260. var
  261. I: Integer;
  262. Path: string;
  263. begin
  264. if FFavoriteComboBox.ItemIndex = 0 then
  265. begin
  266. Path := CurrentFolder;
  267. I := FFavoriteComboBox.Items.IndexOf(Path);
  268. if I > 0 then
  269. begin
  270. // delete current folder
  271. if MessageBox(FHandle,
  272. PChar(Format(LoadResString(@RsOpenDialogDelConfirm), [Path])),
  273. PChar(LoadResString(@RsOpenDialogConfirmation)),
  274. MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2) = ID_YES then
  275. begin
  276. FFavoriteComboBox.Items.Delete(I);
  277. FFavoriteComboBox.Items[0] := FTextAdd;
  278. FFavoriteComboBox.ItemIndex := 0;
  279. end;
  280. end
  281. else
  282. if Path <> '' then
  283. begin
  284. // add current folder
  285. FFavoriteComboBox.ItemIndex := FFavoriteComboBox.Items.Add(Path);
  286. FFavoriteComboBox.Items[0] := FTextDelete;
  287. end;
  288. FFavoriteComboBox.Invalidate;
  289. end
  290. else
  291. if FFavoriteComboBox.ItemIndex > 0 then
  292. // switch to selected folder
  293. CurrentFolder := FFavoriteComboBox.Items[FFavoriteComboBox.ItemIndex];
  294. end;
  295. {$ENDIF OLDSTYLE}
  296. {$IFDEF NEWSTYLE}
  297. procedure TJclOpenDialogFavoritesHook.FileDialogCreate(
  298. const AFileDialog: IFileDialog);
  299. var
  300. FileDialogCustomize: IFileDialogCustomize;
  301. Unused: Cardinal;
  302. begin
  303. inherited FileDialogCreate(AFileDialog);
  304. FileDialogCustomize := AFileDialog as IFileDialogCustomize;
  305. //CheckOSError(FileDialogCustomize.StartVisualGroup(CTRLID_GROUP, PWideChar(WideString(LoadResString(@RsOpenDialogFavorites)))));
  306. CheckOSError(FileDialogCustomize.AddComboBox(CTRLID_COMBOBOX));
  307. //CheckOSError(FileDialogCustomize.EndVisualGroup);
  308. CheckOSError(FileDialogCustomize.MakeProminent(CTRLID_COMBOBOX));
  309. CheckOSError(AFileDialog.Advise(Self, Unused));
  310. end;
  311. procedure TJclOpenDialogFavoritesHook.FileDialogCleanCombobox(
  312. const AFileDialogCustomize: IFileDialogCustomize);
  313. var
  314. I: Integer;
  315. begin
  316. if FComboboxListItem then
  317. CheckOSError(AFileDialogCustomize.RemoveControlItem(CTRLID_COMBOBOX, ITEMID_LIST));
  318. FComboboxListItem := False;
  319. if FComboboxAddItem then
  320. CheckOSError(AFileDialogCustomize.RemoveControlItem(CTRLID_COMBOBOX, ITEMID_ADD));
  321. FComboboxAddItem := False;
  322. if FComboboxDeleteItem then
  323. CheckOSError(AFileDialogCustomize.RemoveControlItem(CTRLID_COMBOBOX, ITEMID_DELETE));
  324. FComboboxDeleteItem := False;
  325. if FComboboxVirtualItem then
  326. CheckOSError(AFileDialogCustomize.RemoveControlItem(CTRLID_COMBOBOX, ITEMID_VIRTUAL));
  327. FComboboxVirtualItem := False;
  328. for I := 0 to FComboboxCount - 1 do
  329. CheckOSError(AFileDialogCustomize.RemoveControlItem(CTRLID_COMBOBOX, I));
  330. FComboboxCount := 0;
  331. end;
  332. procedure TJclOpenDialogFavoritesHook.FileDialogFillCombobox(
  333. const AFileDialogCustomize: IFileDialogCustomize; ListItem, AddItem, DeleteItem, VirtualItem: Boolean);
  334. var
  335. I: Integer;
  336. begin
  337. if ListItem then
  338. CheckOSError(AFileDialogCustomize.AddControlItem(CTRLID_COMBOBOX, ITEMID_LIST, PWideChar(WideString(FTextList))));
  339. FComboboxListItem := ListItem;
  340. if AddItem then
  341. CheckOSError(AFileDialogCustomize.AddControlItem(CTRLID_COMBOBOX, ITEMID_ADD, PWideChar(WideString(FTextAdd))));
  342. FComboboxAddItem := AddItem;
  343. if DeleteItem then
  344. CheckOSError(AFileDialogCustomize.AddControlItem(CTRLID_COMBOBOX, ITEMID_DELETE, PWideChar(WideString(FTextDelete))));
  345. FComboboxDeleteItem := DeleteItem;
  346. if VirtualItem then
  347. CheckOSError(AFileDialogCustomize.AddControlItem(CTRLID_COMBOBOX, ITEMID_VIRTUAL, PWideChar(WideString(FTextVirtual))));
  348. FComboboxVirtualItem := VirtualItem;
  349. FComboboxCount := FFavoriteFolders.Count;
  350. for I := 0 to FComboboxCount - 1 do
  351. CheckOSError(AFileDialogCustomize.AddControlItem(CTRLID_COMBOBOX, I, PWideChar(WideString(FFavoriteFolders.Strings[I]))));
  352. end;
  353. {$ENDIF NEWSTYLE}
  354. procedure TJclOpenDialogFavoritesHook.LoadFavorites(const FileName: string);
  355. begin
  356. if FileExists(FileName) then
  357. FavoriteFolders.LoadFromFile(FileName)
  358. else
  359. FavoriteFolders.Clear;
  360. end;
  361. {$IFDEF NEWSTYLE}
  362. function TJclOpenDialogFavoritesHook.OnButtonClicked(
  363. const pfdc: IFileDialogCustomize; dwIDCtl: DWORD): HResult;
  364. begin
  365. Result := S_OK;
  366. end;
  367. function TJclOpenDialogFavoritesHook.OnCheckButtonToggled(
  368. const pfdc: IFileDialogCustomize; dwIDCtl: DWORD; bChecked: BOOL): HResult;
  369. begin
  370. Result := S_OK;
  371. end;
  372. function TJclOpenDialogFavoritesHook.OnControlActivating(
  373. const pfdc: IFileDialogCustomize; dwIDCtl: DWORD): HResult;
  374. begin
  375. Result := S_OK;
  376. end;
  377. function TJclOpenDialogFavoritesHook.OnFileOk(const pfd: IFileDialog): HResult;
  378. begin
  379. Result := S_OK;
  380. end;
  381. function TJclOpenDialogFavoritesHook.OnFolderChange(
  382. const pfd: IFileDialog): HResult;
  383. var
  384. pfdc: IFileDialogCustomize;
  385. ppsi: IShellItem;
  386. Path: PWideChar;
  387. ItemIndex: Integer;
  388. begin
  389. Result := S_OK;
  390. pfdc := pfd as IFileDialogCustomize;
  391. CheckOSError(pfd.GetFolder(ppsi));
  392. if not Succeeded(ppsi.GetDisplayName(SIGDN_FILESYSPATH, Path)) then
  393. Path := nil;
  394. ItemIndex := FFavoriteFolders.IndexOf(Path);
  395. if ItemIndex = -1 then
  396. begin
  397. if Path <> '' then
  398. begin
  399. FileDialogCleanCombobox(pfdc);
  400. FileDialogFillCombobox(pfdc, True, True, False, False);
  401. CheckOSError(pfdc.SetSelectedControlItem(CTRLID_COMBOBOX, ITEMID_LIST));
  402. end
  403. else
  404. begin
  405. FileDialogCleanCombobox(pfdc);
  406. FileDialogFillCombobox(pfdc, False, False, False, True);
  407. CheckOSError(pfdc.SetSelectedControlItem(CTRLID_COMBOBOX, ITEMID_VIRTUAL));
  408. end;
  409. end
  410. else
  411. begin
  412. FileDialogCleanCombobox(pfdc);
  413. FileDialogFillCombobox(pfdc, False, False, True, False);
  414. CheckOSError(pfdc.SetSelectedControlItem(CTRLID_COMBOBOX, ItemIndex));
  415. end;
  416. end;
  417. function TJclOpenDialogFavoritesHook.OnFolderChanging(const pfd: IFileDialog;
  418. const psiFolder: IShellItem): HResult;
  419. begin
  420. Result := S_OK;
  421. end;
  422. function TJclOpenDialogFavoritesHook.OnItemSelected(
  423. const pfdc: IFileDialogCustomize; dwIDCtl, dwIDItem: DWORD): HResult;
  424. var
  425. I: Integer;
  426. pfd: IFileDialog;
  427. ppsi: IShellItem;
  428. Path: PWideChar;
  429. begin
  430. Result := S_OK;
  431. if dwIDCtl = CTRLID_COMBOBOX then
  432. begin
  433. pfd := pfdc as IFileDialog;
  434. CheckOSError(pfd.GetFolder(ppsi));
  435. if not Succeeded(ppsi.GetDisplayName(SIGDN_FILESYSPATH, Path)) then
  436. Path := nil;
  437. if dwIDItem = ITEMID_DELETE then
  438. begin
  439. I := FFavoriteFolders.IndexOf(Path);
  440. if I >= 0 then
  441. begin
  442. // delete current folder
  443. if MessageBox(0,
  444. PChar(Format(LoadResString(@RsOpenDialogDelConfirm), [Path])),
  445. PChar(LoadResString(@RsOpenDialogConfirmation)),
  446. MB_YESNO or MB_ICONQUESTION or MB_DEFBUTTON2) = ID_YES then
  447. begin
  448. FFavoriteFolders.Delete(I);
  449. FileDialogCleanCombobox(pfdc);
  450. FileDialogFillCombobox(pfdc, True, True, False, False);
  451. CheckOSError(pfdc.SetSelectedControlItem(CTRLID_COMBOBOX, ITEMID_LIST));
  452. end;
  453. end;
  454. end
  455. else
  456. if dwIDItem = ITEMID_ADD then
  457. begin
  458. if Path <> '' then
  459. begin
  460. // add current folder
  461. I := FFavoriteFolders.Add(Path);
  462. FileDialogCleanCombobox(pfdc);
  463. FileDialogFillCombobox(pfdc, False, False, True, False);
  464. CheckOSError(pfdc.SetSelectedControlItem(CTRLID_COMBOBOX, I));
  465. end;
  466. end
  467. else
  468. //if dwIDItem >= 0 then
  469. begin
  470. // switch to selected folder
  471. CheckOSError(SHCreateItemFromParsingName(PWideChar(WideString(FFavoriteFolders.Strings[dwIDItem])), nil, IShellItem, ppsi));
  472. CheckOSError(pfd.SetFolder(ppsi));
  473. FileDialogCleanCombobox(pfdc);
  474. FileDialogFillCombobox(pfdc, False, False, True, False);
  475. CheckOSError(pfdc.SetSelectedControlItem(CTRLID_COMBOBOX, dwIDItem));
  476. end;
  477. end;
  478. end;
  479. function TJclOpenDialogFavoritesHook.OnOverwrite(const pfd: IFileDialog;
  480. const psi: IShellItem; out pResponse: DWORD): HResult;
  481. begin
  482. Result := S_OK;
  483. end;
  484. function TJclOpenDialogFavoritesHook.OnSelectionChange(
  485. const pfd: IFileDialog): HResult;
  486. begin
  487. Result := S_OK;
  488. end;
  489. function TJclOpenDialogFavoritesHook.OnShareViolation(const pfd: IFileDialog;
  490. const psi: IShellItem; out pResponse: DWORD): HResult;
  491. begin
  492. Result := S_OK;
  493. end;
  494. function TJclOpenDialogFavoritesHook.OnTypeChange(
  495. const pfd: IFileDialog): HResult;
  496. begin
  497. Result := S_OK;
  498. end;
  499. function TJclOpenDialogFavoritesHook.QueryInterface(const IID: TGUID;
  500. out Obj): HResult;
  501. begin
  502. if GetInterface(IID, Obj) then
  503. Result := 0
  504. else
  505. Result := E_NOINTERFACE;
  506. end;
  507. function TJclOpenDialogFavoritesHook._AddRef: Integer;
  508. begin
  509. Result := -1;
  510. end;
  511. function TJclOpenDialogFavoritesHook._Release: Integer;
  512. begin
  513. Result := -1;
  514. end;
  515. {$ENDIF NEWSTYLE}
  516. {$IFDEF UNITVERSIONING}
  517. initialization
  518. RegisterUnitVersion(HInstance, UnitVersioning);
  519. finalization
  520. UnregisterUnitVersion(HInstance);
  521. {$ENDIF UNITVERSIONING}
  522. end.