Repository navigation
Expand file tree
/
Copy pathuFilePreviewHandler.pas
More file actions
93 lines (80 loc) · 2.74 KB
/
Copy pathuFilePreviewHandler.pas
File metadata and controls
93 lines (80 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// **************************************************************************************************
//
// Unit uFilePreviewHandler
// unit for the Delphi Preview Handler https://github.com/RRUZ/delphi-preview-handler
//
// 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 uFilePreviewHandler.pas.
//
// The Initial Developer of the Original Code is Rodrigo Ruz V.
// Portions created by Rodrigo Ruz V. are Copyright (C) 2011-2021 Rodrigo Ruz V.
// All Rights Reserved.
//
// *************************************************************************************************
unit uFilePreviewHandler;
interface
uses
ComObj,
uPreviewHandler;
type
TFilePreviewHandler = class abstract(TPreviewHandler)
public
class function GetComClass: TComClass; override; final;
end;
implementation
uses
Windows,
PropSys,
SysUtils,
uLogExcept,
uMisc;
type
TComFilePreviewHandler = class(TComPreviewHandler, IInitializeWithFile)
// strict private
function IInitializeWithFile.Initialize = IInitializeWithFile_Initialize;
function IInitializeWithFile_Initialize(pszFilePath: LPCWSTR; grfMode: DWORD): HRESULT; stdcall;
private
FFilePath: TFileName;
FMode: DWORD;
function GetPreviewHandler: TFilePreviewHandler;
protected
procedure InternalDoPreview; override;
procedure InternalUnload; override;
property PreviewHandler: TFilePreviewHandler read GetPreviewHandler;
property FilePath: TFileName read FFilePath;
property Mode: DWORD read FMode;
end;
function TComFilePreviewHandler.GetPreviewHandler: TFilePreviewHandler;
begin
Result := inherited PreviewHandler as TFilePreviewHandler;
end;
function TComFilePreviewHandler.IInitializeWithFile_Initialize(pszFilePath: LPCWSTR; grfMode: DWORD): HRESULT;
begin
FFilePath := pszFilePath;
Initialize_GDI;
FMode := grfMode;
Result := S_OK;
end;
procedure TComFilePreviewHandler.InternalDoPreview;
begin
TLogPreview.Add('TComFilePreviewHandler.InternalDoPreview');
CheckContainer;
Container.LoadFromFile(FFilePath);
Container.Show;
end;
procedure TComFilePreviewHandler.InternalUnload;
begin
FFilePath := '';
end;
class function TFilePreviewHandler.GetComClass: TComClass;
begin
Result := TComFilePreviewHandler;
end;
end.