-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathf_HelpViewer.pas
More file actions
94 lines (79 loc) · 2.07 KB
/
f_HelpViewer.pas
File metadata and controls
94 lines (79 loc) · 2.07 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
94
unit f_HelpViewer;
(*
Copyright © 2025, 2026
William Meyer All rights reserved.
Markdown-based help viewer. Displays the SBOMgen guide from a
local .md file using TMarkdownViewer. Instantiated on demand
via the class method ShowHelpTopic and freed on close.
*)
(*
MARKDOWN_HELP must be defined as a project option to build with help support.
Project, Options, Delphi Compiler, Conditional Defines
All configurations, 32 or 64 bit. Add MARKDOWN_HELP
*)
interface
uses
System.Classes,
Vcl.Forms,
Vcl.Controls,
Vcl.StdCtrls,
Vcl.ExtCtrls
{$IFDEF MARKDOWN_HELP}
, HTMLUn2,
HtmlView,
MarkDownViewerComponents
{$ENDIF}
;
type
TfrmHelpViewer = class(TForm)
pnlTop: TPanel;
btnClose: TButton;
procedure btnCloseClick(Sender: TObject);
{$IFDEF MARKDOWN_HELP}
private
FMarkdownViewer: TMarkdownViewer;
{$ENDIF}
public
/// <summary>Loads AHelpFile into the viewer and shows the form modally.</summary>
procedure ShowHelp(const AHelpFile: string);
/// <summary>
/// Creates a viewer instance, displays AHelpFile, then frees the form.
/// Call this from any context that needs to show help without managing
/// a persistent form reference.
/// </summary>
class procedure ShowHelpTopic(const AHelpFile: string);
end;
implementation
{$R *.dfm}
uses
System.SysUtils,
System.IOUtils;
procedure TfrmHelpViewer.btnCloseClick(Sender: TObject);
begin
Close;
end;
procedure TfrmHelpViewer.ShowHelp(const AHelpFile: string);
begin
{$IFDEF MARKDOWN_HELP}
FMarkdownViewer := TMarkdownViewer.Create(Self);
FMarkdownViewer.Parent := Self;
FMarkdownViewer.Align := alClient;
if not FileExists(AHelpFile) then
raise EFileNotFoundException.CreateFmt(
'Help file not found: %s', [AHelpFile]);
FMarkDownViewer.LoadFromFile(AHelpFile);
ShowModal;
{$ENDIF}
end;
class procedure TfrmHelpViewer.ShowHelpTopic(const AHelpFile: string);
var
HelpForm: TfrmHelpViewer;
begin
HelpForm := TfrmHelpViewer.Create(nil);
try
HelpForm.ShowHelp(AHelpFile);
finally
HelpForm.Free;
end;
end;
end.