EnableExplicit

LibBuild_Include(GetTextOutWidth)

Procedure.s Ellipsis_TextEnd(hdc.i, xText.s, MaxWidthPX.i)
  Define.s xResult
  Define.i xLong1

  If GetTextOutWidth(hdc, xText) <= MaxWidthPX
    xResult = xText
    Else
    xLong1 = Len(xText) - 1
    While xLong1 >= 0
      xResult = Left(xText, xLong1) + "..."
      If GetTextOutWidth(hdc, xResult) <= MaxWidthPX
        Break
        EndIf
      xLong1 - 1
      Wend
    EndIf
  ProcedureReturn xResult
  EndProcedure

; IDE Options = PureBasic 5.21 LTS (Windows - x86)
; CursorPosition = 2
; Folding = -
; Executable = CleanupEmptyDirs.exe
; CommandLine = "T:\GameMusicRipp\2011\Alien Breed 2 - Assault"
; CompileSourceDirectory