API reference › Rendering & Viewer
rasHaveSelection
Query whether a selection exists, and whether it has
BOOL32 __stdcall rasHaveSelection(IPGC CachePtr);
BOOL32 __stdcall rasHaveSelectedText(IPGC CachePtr);
BOOL32 __stdcall rasGetSelectionPath(IPGC CachePtr, uint32_t PageNum, TPDFObjSelPath* Value);
function rasHaveSelection(CachePtr: IPGC): LongBool; stdcall;
function rasHaveSelectedText(CachePtr: IPGC): LongBool; stdcall;
function rasGetSelectionPath(CachePtr: IPGC; PageNum: Cardinal; var Value: TPDFObjSelPath): LongBool; stdcall;
Purpose. Query whether a selection exists, and whether it has associated extracted text; report the selection as a "path" structure (in practice, a rectangle).
Description. rasHaveSelection reads C.HasSel directly. rasHaveSelectedText additionally requires C.SelTextBuf to be non-empty — since SelTextBuf is only populated by a prior rasGetSelectedText/rasCopyToClipBoard call (not automatically at selection time), rasHaveSelectedText can return False even while a real, non-empty text selection exists, until something has actually extracted it once. rasGetSelectionPath — despite TPDFObjSelPath's name suggesting a general path/polygon — only ever reports a single rectangular BBox (the same normalized selection corners as rasGetSelRect, Zoom, Scroll, Rotate, and Coordinate Mapping) plus PageWidth; and only for the current page — passing a PageNum other than 0 or C.CurrPage returns False rather than reporting an empty/different-page result.
Parameters.
| Parameter | Description |
|---|---|
CachePtr | Target page cache. |
PageNum | 0 or the current page only; any other page number fails. |
Value | Output: BBox (rectangle) + PageWidth; no true multi-segment path is ever produced. |
Return value. True if a selection exists (and, for rasGetSelectionPath, PageNum matches the current page).
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Rasterizer/Rendering
rasHaveSelection
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.