API reference › Rendering & Viewer
vwrShowFile
The complete, self-contained standalone PDF viewer window
BOOL32 __stdcall vwrShowFileW(const wchar_t* FileName, const wchar_t* Title);
function vwrShowFileW(const FileName: PWideChar; const Title: PWideChar): LongBool; stdcall;
Purpose. The complete, self-contained standalone PDF viewer window — open a file and show it in a real Win32 GDI application window with toolbar, bookmark tree, and the full interactive ras* viewer engine wired up internally. Implemented in a separate unit from the rest of this volume, and is the only exported function from it.
Description. Genuinely real and substantial — not a thin wrapper around the ras*/IPGC primitives documented elsewhere in this volume, but the actual reference implementation that would use them internally. Enforces a single-instance guard: a module-global GActive flag means a second concurrent call while a viewer window is already open fails immediately (Result := False) rather than opening a second window or queuing — "one preview at a time" per an inline comment. Validates FileName exists before proceeding. Builds the window chrome (toolbar via MakeToolbar/BuildButtons, a TVS_HASBUTTONS tree-view child window for the bookmark panel via WC_TREEVIEW), registers window classes once (RegisterClassesOnce), and resets a substantial block of module-global UI state (show-bookmarks/ thumbnails/find panel flags, wheel-scroll accumulator, rotation, drag/pan/ selection/single-page-mode flags) before creating the main window — this module-global state means vwrShowFileW is not reentrant or thread-safe for concurrent independent viewers even beyond the explicit GActive guard (consistent with the single-instance design, not a separate bug). Title is optional — if nil or empty, the window caption defaults to 'LumasPDF Preview - ' + <filename>.
Parameters.
| Parameter | Description |
|---|---|
FileName | Path to the PDF to open; must exist. |
Title | Optional window caption override; defaults to a generated "LumasPDF Preview - <filename>" caption. |
Return value. True if the viewer window was created and shown; False if another viewer instance is already active, or FileName is nil/doesn't exist.
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Misc
vwrShowFileW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.