• Da das Thema gerade aktuell ist (_FilePathTrimToLabelWidth), hab ich mal MSDN befragt wie man das macht und bin auf folgende Lösung gekommen:

    Spoiler anzeigen
    [autoit]


    #include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $hGui = GUICreate('_GuiCtrlSetPath by funkey', 600, 200)
    Global $nPath1 = GUICtrlCreateLabel('', 10, 10, 300, 50)
    GUICtrlSetBkColor(-1, 0xCCCCCC)
    GUICtrlSetFont(-1, 30)
    _GuiCtrlSetPath($nPath1, "C:\path1\path2\sample.txt")

    [/autoit] [autoit][/autoit] [autoit]

    Global $nPath2 = GUICtrlCreateLabel('', 10, 80, 580, 60)
    GUICtrlSetBkColor(-1, 0xCCCCCC)
    GUICtrlSetFont(-1, 40)
    _GuiCtrlSetPath($nPath2, "C:\path1\path2\sample.txt")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateInput("", 10, 150, 200, 20)
    _GuiCtrlSetPath(-1, "C:\path1\path2\path3\path4\path5\path6\sample.txt", 4)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState()

    [/autoit] [autoit][/autoit] [autoit]

    Do
    Until GUIGetMsg() = -3

    [/autoit] [autoit][/autoit] [autoit]

    Func _GuiCtrlSetPath($nID, $sPath, $iFit = 0)
    ;coded by funkey
    ;2011, Nov 24th
    Local $hCtrl = GUICtrlGetHandle($nID)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hDC = _WinAPI_GetDC($hCtrl)
    Local $tPath = DllStructCreate("char[260]")
    Local $pPath = DllStructGetPtr($tPath)
    DllStructSetData($tPath, 1, $sPath)

    [/autoit] [autoit][/autoit] [autoit]

    Local $hFont = _SendMessage($hCtrl, 49, 0, 0, 0, "wparam", "lparam", "hwnd") ;WM_GETFONT
    Local $hFont_old = _WinAPI_SelectObject($hDC, $hFont)

    [/autoit] [autoit][/autoit] [autoit]

    Local $aPos = ControlGetPos($hCtrl, "", "")

    [/autoit] [autoit][/autoit] [autoit]

    DllCall("Shlwapi.dll", "BOOL", "PathCompactPath", "handle", $hDC, "ptr", $pPath, "int", $aPos[2] - $iFit)

    [/autoit] [autoit][/autoit] [autoit]

    _WinAPI_SelectObject($hDC, $hFont_old)
    _WinAPI_DeleteDC($hDC)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlSetData($nID, DllStructGetData($tPath, 1))
    Return DllStructGetData($tPath, 1)
    EndFunc ;==>_GuiCtrlSetPath

    [/autoit]

    Edit: Funktionsnamen geändert und ein wenig erweitert. Das ganze funktioniert ja nicht nur bei Labeln

  • Ich habe mal die WinAPIEx gecheckt und da ist bereits die Funktion implementiert... Aber egal!

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯