Help Center

AfxPathCompactPathfunction

Truncates a file path to fit within a given pixel width by replacing path components with ellipses.

String ManagementfunctionAfxPath.incdocumented

Syntax

FUNCTION AfxPathCompactPath (BYVAL hDC AS HDC, BYREF wszPath AS CONST WSTRING, BYVAL dx AS DWORD) AS DWSTRING

Parameters

NameDescription
hDCA handle to the device context used for font metrics. This value can be NULL.
wszPathA string that contains the path to be modified.
dxThe width, in pixels, in which the string must fit.

Return value

The compacted path.

Description

Truncates a file path to fit within a given pixel width by replacing path components with ellipses.

Remarks

This function uses the font currently selected in hDC to calculate the width of the text. This function will not compact the path beyond the base file name preceded by ellipses.

Example

DIM dws AS DWSTRING = AfxPathCompactPath(NULL, "C:\path1\path2\sample.txt", 180)

Reference

  • Include file AfxPath.inc
  • Defined in AfxNova/AfxPath.inc:235
  • Documented in String Management/Path and Url Procedures.md
  • Topic: Path and Url procedures