Function Reference


_WinAPI_PathCompactPath

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

#include <WinAPIShPath.au3>
_WinAPI_PathCompactPath ( $hWnd, $sFilePath [, $iWidth = 0] )

Parameters

$hWnd Handle to the window used for font metrics.
$sFilePath The path to be modified.
$iWidth [optional] The width, in pixels, in which the string must fit. If this parameter is 0 (Default), width will be equal to
the width of the window's client area. If this parameter is a negative number, the width will be
decreased to its absolute value.

Return Value

Success: The modified path.
Failure: The original $sFilePath parameter and sets the @error flag to non-zero.

Remarks

This function will not compact the path beyond the base file name preceded by ellipses.

See Also

Search PathCompactPath in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <WinAPIShPath.au3>

GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 260, 60)
Local $idLabel = GUICtrlCreateLabel('', 10, 22, 240, 16)
Local $hLabel = GUICtrlGetHandle($idLabel)
GUICtrlSetData(-1, _WinAPI_PathCompactPath($hLabel, @ScriptFullPath))
GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE